MySQL creates a database using PHP and mysqlphp creates a database
Use mysqladmin to create a database
For normal users, you may need specific permissions to create or delete MySQL databases.
Therefore, we use the root user to log on. the root user has the highest permissions and can use the mysql mysqladmin command to create a database.
Instance
The following command demonstrates the process of creating a database. The data name is TUTORIALS:
[root@host]# mysqladmin -u root -p create TUTORIALSEnter password:******
After the preceding command is successfully executed, the MySQL database TUTORIALS is created.
Use a PHP script to create a database
PHP uses the mysql_query function to create or delete a MySQL database.
This function has two parameters. TRUE is returned when execution is successful. Otherwise, FALSE is returned.
Syntax
bool mysql_query( sql, connection );
Parameters |
Description |
SQL |
Required. Specifies the SQL query to be sent. Note: The query string should not end with a semicolon. |
Connection |
Optional. Specifies the SQL connection identifier. If not specified, the last opened connection is used. |
Instance
The following example demonstrates how to create a database using PHP:
Address: http://www.manongjc.com/mysql/mysql_create_database.html
Related reading:
- MySQL deletes a database
- MySQL select database
- MySQL Data Type
- Create a data table in MySQL
- MySQL deletes a data table
- Insert MySQL Data
- MySQL query data