Addressing "ERROR 1130: Host Not Allowed to Connect to MySQL Server"
In an attempt to establish a connection to MySQL remotely, users may encounter "ERROR 1130: Host 'xxx.xxx.xxx.xxx' is not allowed to connect to this MySQL server." This error indicates that the root account used for the connection lacks the necessary permissions to establish a remote connection.
To resolve this issue, check if the root account has been granted access to remote connections. Run the following query to verify:
SELECT host FROM mysql.user WHERE User = 'root';
If the results only include 'localhost' and '127.0.0.1,' remote connection is disabled. To enable it:
Add the IP address of the machine from where you want to connect:
CREATE USER 'root'@'ip_address' IDENTIFIED BY 'some_pass';
Grant all necessary privileges:
GRANT ALL PRIVILEGES ON *.* TO 'root'@'ip_address';
If unrestricted access is desired, use the wildcard '%':
CREATE USER 'root'@'%' IDENTIFIED BY 'some_pass'; GRANT ALL PRIVILEGES ON *.* TO 'root'@'%';
Remember to flush the privileges:
FLUSH PRIVILEGES;
Using these steps, you should now be able to connect to MySQL remotely using the root account.
The above is the detailed content of How to Fix MySQL Error 1130: Host Not Allowed to Connect to MySQL Server?. For more information, please follow other related articles on the PHP Chinese website!