Home >Database >Mysql Tutorial >How to Fix MySQL Error 1130: Host Not Allowed to Connect to MySQL Server?

How to Fix MySQL Error 1130: Host Not Allowed to Connect to MySQL Server?

Barbara Streisand
Barbara StreisandOriginal
2025-01-01 06:33:11607browse

How to Fix MySQL Error 1130: Host Not Allowed to Connect to MySQL Server?

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:

  1. Add the IP address of the machine from where you want to connect:

    CREATE USER 'root'@'ip_address' IDENTIFIED BY 'some_pass';
  2. Grant all necessary privileges:

    GRANT ALL PRIVILEGES ON *.* TO 'root'@'ip_address';
  3. 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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn