Skip to main content

Solve 1130-Host is not allowed to connect to this MySQL server and achieve remote connection to the local database

When using Navicat to remotely connect to a local database, I encountered such a problem:

I use the address of the local host to connect to the local database, and the error host '' is not allowed to connect to this mysql server is reported.

I checked the information on the Internet and found that mysql installed locally does not allow remote login by default. If you want to remotely access the local database, you need to modify the access permissions. Change the 'root' access permission to '%'. The specific operations are as follows :

1.LoginMysql

win+R enter cmd

Open the terminal control panel

Enter mysql -u root -p

Enter the password and log in to mysql

2.Enter the mysql library

Enter use mysql

Switch database

3.Execute update permission statement

update user set Host='%' where User='root';

Among them, "%" represents all addresses, which means that all addresses can access "root"

4.View permissions

Enter select host,user from user;

Check whether the modification is successful

5.Refresh server configuration

Enter FLUSH PRIVILEGES;

(The essential function of the flush privileges command is to extract the user information/permission settings in the current user and privilege tables from the mysql library (the built-in library of the MySQL database) into memory. After the MySQL user data and permissions are modified, I hope that " "It will take effect directly without restarting the MySQL service", then you need to execute this command. Usually after modifying the settings of the ROOT account, you are afraid that you will no longer be able to log in after the restart, so you can directly flush to see whether the permission settings take effect. No need Take too much risk. After changing the password of mysql, pay attention to flush privileges. After setting a new user or changing the password of mysql, you need to use flush privileges to refresh the MySQL system permissions related table. Otherwise, access will be denied. Another way is to restart the mysql server. , to make the new settings take effect.)

6.Enter Navict to test the connection