Home >Database >Mysql Tutorial >How to solve the problem that mysql cannot connect to the remote server
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:
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;
You can use the following statement to modify the access permissions of all hosts
update user set host = '%' where user = 'root';
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;
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!