Home >Database >Mysql Tutorial >How to solve the problem of Mysql limiting connection and reporting 1130
Remotely connect to the MySQL server database, the error code is 1130, ERROR 1130: Host xxx.xxx.xxx.xxx is not allowed to connect to this MySQL server
Guess two reasons: one is because of MySQL restrictions, One is firewall restrictions.
1. Solve the firewall restriction:
Turn off the firewall on the MySQL service host or add inbound and outbound rules in the advanced firewall settings, add the MySQL port, and allow access to the host through the MySQL port.
Modify the firewall configuration (the system is different, the firewall configuration file is different) The blogger's is iptables installed under centos7
$ vi /etc/sysconfig/iptables
After opening it, add a line to the configuration file
-A RH-Firewall-1-INPUT -p tcp -m state --state NEW -m tcp --dport 3306 -j ACCEPT
Then save and exit
Restart the firewall (centos7)
systemctlrestart iptables.service
2. Solve the limitations of MySQL and execute the following sql on the MySQL service host
After logging in to mysql on the local machine , change the "host" item in the "user" table in the "mysql" database, rename it from "localhost" to '%'
Log in to mysql
mysql -u root -p
Select the mysql database
mysql;use mysql;
Check the host value of the user table in the mysql library (that is, the host/IP name for connection access)
mysql;select 'host' from user where user='root';
Modify the host value (increase the host/IP address with wildcard % content), of course You can also add the IP address directly
If there is an error in this step "ERROR 1062 (23000): Duplicate entry '%-root' for key 'PRIMARY'" It means that the record exists, skip this step
mysql;update user set host = '%' where user ='root';
Change permissions (root is the account name, % is the host name (any host), 525099302 is the password You can choose the password yourself)
GRANT ALL PRIVILEGES ON *.* TO root@'%' IDENTIFIED BY "525099302";
Refresh permissions, mysql will take effect directly
flush privileges;
Restart the mysql service to complete.
The above is the detailed content of How to solve the problem of Mysql limiting connection and reporting 1130. For more information, please follow other related articles on the PHP Chinese website!