First connect to MySQL ：
mysql -u root -p;
Then switch to mysql database:
The command below shows the current users and their encrypted password and hosts:
select host,user,password from user;
By default, you can see that only localhost can connect to database.
The command below shows how to add a new user named user and set up its password to 123456 and then allow it to access MySQL at host 192.168.1.100;
GRANT ALL PRIVILEGES ON * . * TO 'user'@'192.168.1.100' IDENTIFIED BY '123456' WITH GRANT OPTION;
NOTE: Replacing the ip above with the char % allows all ip address to access database. Thus the result should be: GRANT ALL PRIVILEGES ON * . * TO 'user'@'%' IDENTIFIED BY '123456' WITH GRANT OPTION;
Finally flush changes:
Restart your mysql service:
service mysql restart
Now you can access MySQL in your local host client like Navicat.
Subscribe to JuniperPhoton's Blog
Get the latest posts delivered right to your inbox