MySQL | Adding new user accounts to MySQL server

Do you need a new user for your database running on MySQL server?

1. Access to MySQL with the root username, remember that the root account must have INSERT privileges to the mysql database, use the following command:

Linux console

$ mysql -u root -p

2. *GRANT access to the required database:

Linux console

mysql> GRANT ALL PRIVILEGES ON *.* TO ‘user’@’localhost’
-> IDENTIFIED BY ‘password’ WITH GRANT OPTION;
mysql> GRANT ALL PRIVILEGES ON *.* TO ‘user’@’%’
-> IDENTIFIED BY ‘password’ WITH GRANT OPTION;

The accounts created on step # 2 have full privileges to do anything, one of the accounts can be used only when connecting from localhost, the other one can be used when connection from any other host.

That’s all.

Leave a Reply

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload the CAPTCHA.