Navicat connects to MySQL remotely and prompts 1045 - Access denied for user 'root'@'120.33.156.121'(using password: YES)

Navicat connects to MySQL remotely and prompts 1045 - Access denied for user 'root'@'120.33.156.121'(using password: YES)

Question:
  I installed a MySQL5.7.26 on my Alibaba Cloud server (Window Server2012 R2) today. It is normal to use a local link in the Alibaba Cloud server, but when I use Navicat to connect on my computer, it prompts: 1045 - Access denied for user 'root'@'120.33.156.121'(using password: YES) exception.
Reason for exception:
Although the user name and password are correct, there is no access permission on other ip addresses. You need to log in to MySQL and modify the ip access rights.

Solution:
Since I deploy mysql with docker, I use docker exec -it mysql bash to enter the mysql container first, and use root to log in (enter the correct password):
mysql -u root -p
to set the remote access authority of the MySQL database :

GRANT ALL PRIVILEGES ON *.* TO '登录用户名(如:root)'@'%' IDENTIFIED BY '登录密码(如:123456)' WITH GRANT OPTION;

// Format: GRANT permission ON database name. table name TO user @login host IDENTIFIED BY "user password"; @ is
followed by the client IP address (or host name) to access MySQL % represents any client, if you fill in localhost
For local access (then this user cannot remotely access the mysql database)

Refresh MySQL database permissions:

FLUSH PRIVILEGES;

Enter the account password you just set in Navicat to connect to the database:

Guess you like

Origin blog.csdn.net/weixin_48453772/article/details/129291590