Create by connecting to the MySQL server and using the following steps: connect to the server, create the database using the CREATE DATABASE statement, and check whether the database is created successfully.
How to create a database in MySQL
The process of creating a MySQL database is very simple and can be completed by following the steps :
Connect to the MySQL server using command line tools or the graphical user interface (GUI). For example, using the command line tool, type the following command:
<code class="shell">mysql -u username -p</code>
where username
is your MySQL username and the -p
option prompts you for your password.
Use the CREATE DATABASE
statement to create a database. The syntax is as follows:
<code class="sql">CREATE DATABASE database_name;</code>
where database_name
is the name of the database you want to create. For example:
<code class="sql">CREATE DATABASE my_database;</code>
Use the SHOW DATABASES
statement to check whether the database has been successfully created.
<code class="sql">SHOW DATABASES;</code>
You should see the newly created database in the list.
Other Notes:
The above is the detailed content of How to create a database using mysql. For more information, please follow other related articles on the PHP Chinese website!