After mysql is successfully installed, an error occurs during remote connection.

Host is not allowed to connect to this MySQL server。

Today, after installing MySQL on Windows 10, I found that I can log in locally (Navicat Premium 15), but when I connect to mysql through the go language program, I get the error Host is not allowed to connect to this MySQL server (the part about mysql in the go program is definitely correct) ), the solution here is specially recorded for later review.

Let’s talk about this error first. In fact, our MySQL does not allow remote login, so the remote login fails. The solution is as follows:

1. Log in to MySQL on the machine where MySQL is installed mysql -u root -p password;

2. Execute use mysql;

3. Execute update user set host = '%' where user = 'root'; an error may be reported after executing this sentence, so don't worry about it.

4. Execute FLUSH PRIVILEGES;

After the above 4 steps, you can solve this problem.
 

Guess you like

Origin blog.csdn.net/weixin_59244784/article/details/131898807