我的个人博客:https://lixiaohui.live
原因:
mysql8 之前的版本中加密规则是mysql_native_password
,而在mysql8之后,加密规则是caching_sha2_password
。那么我们需要把mysql用户登录密码加密规则还原成mysql_native_password
。
解决方法:
1).打开命令行小黑屏,进入MySQL的bin目录,然后输入mysql -u root -p
,输入密码,如下所示:
C:\Users\v_xmmxhli>cd C:\Program Files\MySQL\MySQL Server 8.0\bin
C:\Program Files\MySQL\MySQL Server 8.0\bin>mysql -u root -p
Enter password: *****
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 23
Server version: 8.0.12 MySQL Community Server - GPL
Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>
2).然后输入
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password'; #更新一下用户的密码
FLUSH PRIVILEGES; #刷新权限
窗口给出的反应是:
mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'Mysql';
Query OK, 0 rows affected (0.20 sec)
mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.05 sec)
3).再次在Navicat里验证一下,连接成功
Note:注意中英文单引号不要输错了~