默认身份验证插件caching_sha2_password
在MySQL 8里面的默认身份验证插件已经从mysql_native_password变成了caching_sha2_password。
root@da2ac5ce6f38:/# mysql -uroot -pdingjia --protocol=tcp -hmysql80 Warning: Using a password on the command line interface can be insecure. ERROR 2059 (HY000): Authentication plugin 'caching_sha2_password' cannot be loaded: /usr/lib/mysql/plugin/caching_sha2_password.so: cannot open shared object file: No such file or directory root@da2ac5ce6f38:/# mysql -uscutech -pdingjia --protocol=tcp -hmysql80 Warning: Using a password on the command line interface can be insecure. Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 14 Server version: 8.0.19 MySQL Community Server - GPL Copyright (c) 2000, 2020, 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>
解决办法有两个一个是升级客户端,一个修改服务端的认证插件
ALTER USER 'scutech'@'%' IDENTIFIED WITH mysql_native_password BY 'dingjia'; mysql> SELECT Host, User, plugin from mysql.user; +-----------+------------------+-----------------------+ | Host | User | plugin | +-----------+------------------+-----------------------+ | % | root | caching_sha2_password | | % | scutech | mysql_native_password | | localhost | mysql.infoschema | caching_sha2_password | | localhost | mysql.session | caching_sha2_password | | localhost | mysql.sys | caching_sha2_password | | localhost | root | caching_sha2_password | +-----------+------------------+-----------------------+