Solution to being unable to connect to mysql remotely: 1. Log in to mysql; 2. Execute [grant all on database name.* to 'database account name'@'%' identified by 'password' with grant option;] Command; 3. Refresh permissions.
Question:
The following prompt message appears when connecting to the mysql database remotely:
(Recommended tutorial: mysql Video tutorial)
“MYSQL CONNECT ERROR – 1130:Host ’202.43.**.**’ is not allowed to connect to this MySQL server”
When creating a mysql account, restrict remote login of the connecting account. In other words, except for the current installation server where mysql is located, other IPs (hosts) are not allowed to access, even if your username and password are correct. At this time, it is necessary to modify the user's access rights.
Solution:
First log in to the mysql installation host with the root user, and then enter mysql:
mysql -u root -p
root is the highest authorized user name of mysql, then it will You will be prompted to enter your password. Enter the password correctly and press Enter to enter mysql. Enter
Then enter the following command:
grant all on 数据库名.* to ‘数据库账户名’@’%’ identified by ‘密码’ with grant option;
Enter
flush privileges;
Enter
Note: The single quotes above cannot be omitted, database name.* Indicates all tables under the database to be opened. If all databases of the connection are to be opened, *.* can be used instead.
‘Database account name’@’%’ here indicates the account to be opened, and the percent sign indicates that access is allowed on any host.
If both the above two steps show "Query OK, 0 rows affected (0.00 sec)", then the command has been successfully executed and you can now connect to your mysql database remotely.
Related recommendations: mysql tutorial
The above is the detailed content of What should I do if I cannot connect to mysql remotely?. For more information, please follow other related articles on the PHP Chinese website!