Skip to main content

How to create a database and user MySQL



If you don’t have any convenient administration panel installed on your server and you need to add a user and a mysql database to create the site, you can do it through the console.



First, connect to the mysql server.

  # mysql -u root -p 

At the same time, the administrator password will be requested.

Create a database:


  mysql> CREATE DATABASE `db`; 

replace name with database name.

The next step is to create a database user. In the console, type the command:

  mysql> CREATE USER 'name' @ 'localhost' IDENTIFIED BY 'password'; 

Here you need to replace the name with the username and the password with the password for this user.



The last step is to issue all the privileges to the database for the created user. Run the following command, replacing db with the name of the database, and name with the name of the user.

  mysql> GRANT ALL PRIVILEGES ON `db`. * TO 'name' @ 'localhost'; 

Update privileges with the command:

  mysql> FLUSH PRIVILEGES; 


How do you rate the article?
Звёзд: 1Звёзд: 2Звёзд: 3Звёзд: 4Звёзд: 5 ( 19 ratings, average: 4.58 out of 5)
Loading...

Add a comment

Your email will not be published.