Get the App
SLTechnology News&Howtos  ›  Database  › 

The method that mysql can not connect to the remote server

Shulou Source: shulou.com Published: 2022-06-01 02:28:43 10月14日 Update

This article will explain in detail how mysql can not connect to a remote server. The editor thinks it is very practical, so I share it with you as a reference. I hope you can get something after reading this article.

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

How to solve the problem that mysql can not connect to a remote server:

After logging in to the mysql server, you can use the following query statement to see if remote access is enabled. The query results show that only local root users are 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'

However, after executing this statement, I found that there was an error, reporting ERROR 1062 (23000): Duplicate entry'%-root' for key 'PRIMARY'.

Later, I looked for it on the Internet and said it was caused by the "only index"! Let's check whether the incoming data is "duplicate", but this is the user table, and I didn't insert the data manually, and of course I can't delete the data from the user table at will, so I found another way to ignore the error directly.

Just execute the following command directly

Flush privileges; about mysql can not connect to the remote server method to share here, I hope that the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.

Tags: Server service method statement data permissions user host command more article user table query login good practical code content manual article Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Docker MariaDB Shulou Technology Linux Shulou Information