Home > Database > Mysql Tutorial > What should I do if I cannot connect to mysql remotely?

What should I do if I cannot connect to mysql remotely?

王林
Release: 2020-10-14 16:25:37
Original
7030 people have browsed it

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.

What should I do if I cannot connect to mysql remotely?

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”
Copy after login

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

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

Enter

flush privileges;
Copy after login

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!

Related labels:
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template