How to create a new MySQL database? Connect to the MySQL server. Run command: CREATE DATABASE database_name; Grant access to other users (optional). Refresh permissions: FLUSH PRIVILEGES;
How to create a new MySQL database
Step 1: Connect to MySQL Server
Connect to the MySQL server using a terminal or command prompt. Enter the following command:
<code>mysql -u root -p</code>
Among them,
-u root
specifies the user name root-p
Tips Enter the password Step 2: Create the database
After connecting to the server, run the following command to create the database:
<code>CREATE DATABASE database_name;</code>
Where, database_name
is the name of the database to be created.
Step Three (Optional): Grant Permissions
If you need to grant other users access to the new database, run the following command:
<code>GRANT ALL ON database_name.* TO username;</code>
Among them,
username
is the username to which permissions are to be granted ALL
Grant all permissions*
Grant permissions to all tables in the databaseStep 4: Refresh permissions
Finally, refresh permissions to apply the changes:
<code>FLUSH PRIVILEGES;</code>
The above is the detailed content of How to create a new database mysql. For more information, please follow other related articles on the PHP Chinese website!