How to create a MySQL database
Step 1: Connect to the MySQL server
mysql -u 用户名 -p 密码
Step 2: Create the database
CREATE DATABASE
Command to create a database, the syntax is as follows:CREATE DATABASE database_name;
database_name
is the name of the database you want to create.Example:
CREATE DATABASE my_database;
Step 3: Select new database (optional)
USE
command with the following syntax:USE database_name;
Example:
USE my_database;
Step 4: Grant permissions (optional)
GRANT
command with the following syntax:GRANT <权限> ON database_name TO <用户名>;
my_user
all permissions to themy_database
database, you can use the following command:GRANT ALL ON my_database TO my_user;
Step 5: Refresh permissions
FLUSH PRIVILEGES
command to refresh the permissions:FLUSH PRIVILEGES;
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!