1. 程式人生 > >MySQL 8.0報錯:ERROR 2059 (HY000): Authentication plugin 'caching_sha2_password' cannot be loaded

MySQL 8.0報錯:ERROR 2059 (HY000): Authentication plugin 'caching_sha2_password' cannot be loaded

報錯資訊:

error 2059: Authentication plugin 'caching_sha2_password' cannot be loaded: /usr/lib64/mysql/plugin/caching_sha2_password.so: cannot open shared object file: No such file or directory 

原因:

    mysql> select version();  
    +-----------+  
    | version() |  
    +-----------+  
    | 8.0.11    |  
    +-----------+  
1 row in set (0.00 sec) mysql> show variables like 'default_authentication_plugin'; +-------------------------------+-----------------------+ | Variable_name | Value | +-------------------------------+-----------------------+ | default_authentication_plugin | caching_sha2_password | +-------------------------------+-----------------------+
1 row in set (0.01 sec) mysql> select host,user,plugin from mysql.user; +-----------+------------------+-----------------------+ | host | user | plugin | +-----------+------------------+-----------------------+ | % | root | caching_sha2_password | | localhost | mysql.infoschema | mysql_native_password | | localhost | mysql.session | mysql_native_password | | localhost | mysql.sys | mysql_native_password | | localhost | root | caching_sha2_password | +-----------+------------------+-----------------------+
5 rows in set (0.00 sec)

可以看到MySQL8.0.11版本預設的認證方式是caching_sha2_password,連線不上的原因在於連線資料庫工具不支援該格式的密碼。

解決方法:

ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY 'root';

修改密碼加密方式