Home > Database > Mysql Tutorial > body text

How to solve the problem that mysql cannot connect to the remote server

coldplay.xixi
Release: 2020-10-19 14:52:15
Original
2945 people have browsed it

To solve the problem that mysql cannot connect to the remote server: first log in to the mysql server; then use the statement to modify the access permissions of all hosts, the code is [update user set host = '%' where user = 'root'] ; Finally, just execute the following command to resolve the error.

How to solve the problem that mysql cannot connect to the remote server

How to solve the problem that mysql cannot connect to the remote server:

After logging in to the mysql server, you can use the following Use the query statement to check whether remote access permissions are enabled. The query results show that only the local root user is allowed to connect.

select host,user,password from user;
Copy after login

You can use the following statement to modify the access permissions of all hosts

update user set host = '%' where user = 'root';
Copy after login

But after executing this statement, an error was reported, ERROR 1062 (23000): Duplicate entry '%- root' for key 'PRIMARY'

Later, I searched online and found that it was caused by the "unique index"! Let's check whether the entered data is "duplicate", but this is a user table. I didn't insert data manually. Of course, I can't delete the data in the user table at will, so I found another method and ignored this directly. Error

Just execute the following command directly

flush privileges;
Copy after login

More related free learning recommendations:mysql tutorial (video)

The above is the detailed content of How to solve the problem that mysql cannot connect to the remote server. 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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!