Mysql Database Remote Access settings
1. Modify localhost
Change the "host" entry in the "user" table in the "mysql" database to "%" from "localhost"
Mysql> use mysql;
Mysql> update user set host = '%' where user = 'root ';
Mysql> select host, user from user;
Mysql> flush privileges;
2. Specify authorization
Use myuser/mypassword to connect to the mysql server from any host:
Grant all privileges on *. * TO 'myuser' @ '%' identified by 'mypassword' with grant option;
Use myuser/mypassword to connect to the mysql server from a host with the ip address 192.168.225.166:
Grant all privileges on *. * TO 'myuser' @ '192. 168.225.166 'identified BY 'mypassword' with grant option;
3. wildcard authorization
Mysql-h localhost-u root
Mysql> grant all privileges on *. * TO 'root' @ '%' with grant option; // GRANT data access permissions TO any host as root.
Mysql> flush privileges;
Solve the problem that Mysql cannot be remotely connected.
1. Is the Mysql port correct?
Use netstat-ntlp to check port usage. Generally, the port is 3306. A port is used to connect to MySQl using tools. For example, My Admin \ My Query Browser \ MySQl Front.
2. Check whether the user permissions are correct.
The user table of the mysql database has two records: localhost and % (for security purpose, % can be replaced by the IP address you need to connect to the external database ).
3. Check whether skip-networking has been injected in/etc/mysql/my. cnf.
Need to be noted out
ERROR: ERROR 2003 (HY000): Can't connect to MySQL server on '192. 168.51.112 '(192)
Sudo gedit/etc/mysql/my. cnf
# Skip-external-locking
# Bind-address = 127.0.0.1
Skip-name-resolve
4. Check whether iptables is stopped. If no, the connection fails.
Service iptables stop is temporarily disabled.
ERROR: ERROR 2003 (HY000): Can't connect to MySQL server on '192. 168.51.112 '(192)