分析:
在mysql8之前的版本使用的密码加密规则是mysql_native_password,但是在mysql8则是caching_sha2_password
处理办法:
进入数据库
root@6d1f27a83296:/# mysql -u root -p
Enter password:
mysql> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
先查询用户密码加密规则
mysql> select user,host,plugin from user;
+------------------+-----------+-----------------------+
| user | host | plugin |
+------------------+-----------+-----------------------+
| root | % | caching_sha2_password |
| mysql.infoschema | localhost | caching_sha2_password |
| mysql.session | localhost | caching_sha2_password |
| mysql.sys | localhost | caching_sha2_password |
+------------------+-----------+-----------------------+
执行下边的命令,修改指定用户(我的是root)指定加密规则为:mysql_native_password
mysql> ALTER USER root@'%' IDENTIFIED WITH mysql_native_password BY '你的密码';
刷新一下权限
mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.01 sec)
然后再次查询一下用户的密码加密规则
mysql> select user,host,plugin from user;
+------------------+-----------+-----------------------+
| user | host | plugin |
+------------------+-----------+-----------------------+
| root | % | mysql_native_password |
| mysql.infoschema | localhost | caching_sha2_password |
| mysql.session | localhost | caching_sha2_password |
| mysql.sys | localhost | caching_sha2_password |
此时已经修改,然后再次用客户端连接就可以了