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';

修改密码加密方式

你可能感兴趣的:(mysql)