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
Release: 2025-01-01 06:33:11
Original
599 people have browsed it

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';
Copy after login

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';
    Copy after login
  2. Grant all necessary privileges:

    GRANT ALL PRIVILEGES ON *.* TO 'root'@'ip_address';
    Copy after login
  3. If unrestricted access is desired, use the wildcard '%':

    CREATE USER 'root'@'%' IDENTIFIED BY 'some_pass';
    GRANT ALL PRIVILEGES ON *.* TO 'root'@'%';
    Copy after login

Remember to flush the privileges:

FLUSH PRIVILEGES;
Copy after login

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!

source:php.cn
Statement of this Website
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
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template