MySQL: Giving “grant” permissions for a user

2012-06-26 Databases

To be able to connect with a database using GUI (for example MySQL Workbench) it is necessary to set up specific connections. But before that, You'll have to get specific permissions to a computer from which You want to establish connection. See an example below how to give these permissions in the Terminal.

Open it with CTRL + ALT + T and connect to a database server using "ssh":

ssh -l root 10.1.0.172

Enter MySQL:

mysql

Show all permissions – type:

show grants;

As a result You should see something similar to:

+---------------------------------------------------------------------+
| Grants for [email protected]                                           |
+---------------------------------------------------------------------+
| GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' WITH GRANT OPTION |
+---------------------------------------------------------------------+
1 row in set (0,00 sec)

To give yourself all permissions type:

GRANT ALL PRIVILEGES ON *.* TO 'root'@'10.1.1.42' identified by 'myPassword' WITH GRANT OPTION;

Don't forget to change IP to Your address (ifconfig) and password value. Now You should see:

Query OK, 0 rows affected (0,00 sec)

Be careful and don't overwrite permission for localhost root account!

Leave MySQL and whole server and type twice:

exit

Now You can easily establish connection in You database manager.

Do NOT follow this link or you will be banned from the site!