Set MySQL database to allow remote connection in Linux
If the following error occurs when you use a client tool to connect to a MySQL database in Linux:
Host '192. 168.1.3 'is not allowed to connect to this MySQL server solution:
1. Access the mysql database on a Linux host
[Root @ mail ~] # Mysql-u root-p root
Solution if the prompt "Can't connect to local MySQL server through socket" appears
Modify/etc/my. cnf
[Mysqld]
Datadir =/database/mysql
Socket =/database/mysql. sock
[Client]
Socket =/database/mysql. sock
The reason why you want to modify the client section is that, from time to time, the mysql client program will still be connected to/var/lib/mysql. the socket sock goes above. Even though the database has been started normally, whether www.bkjia.com uses mysql to connect to the database will still report that/var/lib/mysql cannot be found. sock Error
2. Connect to the database and run
(1) Change the table method. Change the "host" entry in the "user" table in the "mysql" database, and rename it "%" from "localhost"
Mysql-u root-pvmwaremysql> use mysql; mysql> update user set host = '%' where user = 'root'; mysql> select host, user from user;
(2). Authorization Law
Grant all on *. * to 'root' @ '10. 1.1.201 'identified by 'root ';
Then, the user with the ip address 10.1.1.201 can remotely connect to the database.