How to create a MySQL database
Step 1: Connect to the MySQL server
<code>mysql -u 用户名 -p 密码</code>
Step 2: Create the database
CREATE DATABASE
Command to create a database, the syntax is as follows: <code>CREATE DATABASE database_name;</code>
database_name
is the name of the database you want to create. Example:
<code>CREATE DATABASE my_database;</code>
Step 3: Select new database (optional)
USE
command with the following syntax: <code>USE database_name;</code>
Example:
<code>USE my_database;</code>
Step 4: Grant permissions (optional)
GRANT
command with the following syntax: <code>GRANT <权限> ON database_name TO <用户名>;</code>
my_user
all permissions to the my_database
database, you can use the following command: <code>GRANT ALL ON my_database TO my_user;</code>
Step 5: Refresh permissions
FLUSH PRIVILEGES
command to refresh the permissions: <code>FLUSH PRIVILEGES;</code>
The above is the detailed content of How to create mysql database. For more information, please follow other related articles on the PHP Chinese website!