I reinstalled the computer and installed the latest version of the MySQL database. As a result, Navicat reported a 1251 error when connecting to Mysql, and sqlyog reported a 2058 error. However, the window command entered mysql, and the account and password were correct. .
I checked online that the reason for this is that the encryption rule in versions before mysql8 is mysql_native_password, but after mysql8, the encryption rule is caching_sha2_password.
There are two ways to solve the problem. One is to upgrade the navicat driver; the other is to restore the mysql user login password encryption rule to mysql_native_password.
Related recommendations: "Navicat for mysql graphic tutorial"
I often use the second method:
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password'; #修改加密规则 ALTER USER 'root'@'localhost' IDENTIFIED BY 'password' PASSWORD EXPIRE NEVER; #更新一下用户的密码 FLUSH PRIVILEGES; #刷新权限
I think many people It is wrong to copy directly with the command.
'root' The user name defined for yourself
'localhost' refers to the IP open to the user, which can be 'localhost' (only local access, equivalent to 127.0.0.1) , it can be a specific '*.*.*.*' (a specific IP), or it can be '%' (all IPs can be accessed)
'password' is the user password you want to use
In this way, the problem is solved.
The above is the detailed content of How to solve the 1251 error when establishing connection between mysql and navicat. For more information, please follow other related articles on the PHP Chinese website!