Home >Database >Mysql Tutorial >Why Am I Getting MySQL Error 1130: 'Host 'host_ip' is not allowed to connect to this MySQL server'?

Why Am I Getting MySQL Error 1130: 'Host 'host_ip' is not allowed to connect to this MySQL server'?

Patricia Arquette
Patricia ArquetteOriginal
2024-12-03 13:16:11260browse

Why Am I Getting MySQL Error 1130:

Making Remote Connections to MySQL: Troubleshooting ERROR 1130

MySQL error 1130, "Host 'host_ip' is not allowed to connect to this MySQL server," occurs when an external system attempts to establish a connection to a MySQL server but is denied due to access restrictions.

The root cause of this error lies in the MySQL user account configuration. By default, MySQL accounts may be restricted to specific host systems, such as localhost or 127.0.0.1. To verify this, execute the following query:

SELECT host FROM mysql.user WHERE User = 'root';

If the results only display localhost or 127.0.0.1, remote connections will be blocked. To enable remote access, follow these steps:

1. Add Authorized IP Addresses:

Grant access to the desired IP addresses by creating new user accounts:

CREATE USER 'root'@'ip_address' IDENTIFIED BY 'some_pass';

2. Grant Privileges:

Assign the necessary privileges to the new accounts:

GRANT ALL PRIVILEGES ON *.* TO 'root'@'ip_address';

3. Reload Permissions:

Make the changes take effect by flushing the privileges:

FLUSH PRIVILEGES;

4. Use Wildcard for Any Remote Access:

If you wish to allow any remote system to connect via root, use the % wildcard:

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

By completing these steps, you should be able to successfully connect to the MySQL server from remote systems using the authorized user accounts.

The above is the detailed content of Why Am I Getting MySQL Error 1130: 'Host 'host_ip' is not allowed to connect to this 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