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.

About javier

Mexicano, Ingeniero en Sistemas egresado del Instituto Tecnológico de Durango, Maestro en Software Libre por la Universidad Autónoma de Chihuahua. Apasionado de medio tiempo de la fotografía y guitarrista de closet.
This entry was posted in MySQL, Software, Tips. Bookmark the permalink.

Leave a Reply

Your email address will not be published.