Subject: Grant and revoke remote root access to MySQL
Author: Linux
In response to: How to enable remote access to MySQL?
Posted on: 10/26/2011 02:11:30 AM
To grant root access from all hosts (except for localhost):
mysql> GRANT ALL PRIVILEGES ON *.* TO root@"%" IDENTIFIED BY 'secret';
To revoke root access from all hosts (except for localhost):
mysql> DELETE FROM mysql.user WHERE User = 'root' AND Host = '%';
mysql> FLUSH PRIVILEGES;
>
> On 10/26/2011 02:05:35 AM
Linux wrote:
Connect to mysql server:
$ mysql -u root -p secret
Create a new database called foo
mysql> CREATE DATABASE foo;
If you want database foo to be accessed by user bar from remote ipAddress 12.34.56.78, then you need to type the following command
mysql> GRANT ALL ON foo.* TO bar@'12.34.56.78' IDENTIFIED BY 'secret';
References: