After we landed MySQL service, use the create command to create a database with the following syntax:
CREATE DATABASE database name;
The following command simply demonstrates the creation of the database, the data called CODERCTO:
[root@host]# mysql -u root -p
Enter password: After logging into the terminal ****** #
mysql> create DATABASE CODERCTO;
Create a database using the mysqladmin
Regular user, you may need special permissions to create or delete MySQL database.
So here we are logged in as root, root user has the highest authority, you can use mysql mysqladmin command to create the database.
The following command simply demonstrates the creation of the database, the data called CODERCTO:
[root@host]# mysqladmin -u root -p create CODERCTO
Enter password:******
After the successful implementation of the above command will create a MySQL database CODERCTO.
Create a database using PHP script
Mysqli_query use PHP functions to create or delete MySQL database.
This function takes two arguments and returns TRUE if executed successfully, otherwise it returns FALSE.
grammar
mysqli_query(connection,query,resultmode);
Parameter Description
connection required. MySQL provisions connection to use.
query the necessary provisions query string.
resultmode optional. A constant. It can be any of the following values:
MYSQLI_USE_RESULT (If you need to retrieve large amounts of data, use this)
MYSQLI_STORE_RESULT (default)
Examples
The following example demonstrates the use PHP to create a database:
Create a database
'; $ Sql =' CREATE DATABASE CODERCTO '; $ retval = mysqli_query ($ conn, $ sql); if ($ retval!) {Die (' create the database failed:. 'Mysqli_error ($ conn));} echo "Database CODERCTO successfully created \ n "; mysqli_close ($ conn);?>
Click to see all MySQL Tutorial Articles: https://www.codercto.com/courses/l/30.html (edit: Leilin Peng Source: network intrusion deleted)