Linux MySQL客户端的error 2059

“error 2059: Authentication plugin ‘caching_sha2_password’ cannot be loaded”

 

 

 

问题描述

在 VMware 虚拟机的客户机 CentOS7 里面安装运行有 Docker 的 MySQL 8.0,由于当前 CentOS7 默认的 MySQL 客户端版本太低(5.5.60)(低版本的客户端认 mysql_native_password 认证插件,而高版本认 caching_sha2_password 插件) ,导致连接服务器时出现以下的错误:

 

 

1

2

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

 

 

解决办法

  1. 用高版本的 MySQL,或者进入该 Docker 容器,登录 MySQL 服务器。
  2. 执行 MySQL shell 命令查看服务器的版本:

     

     

    1

    2

    > select version();

     

     

    执行结果:

     

     

    1

    2

    3

    4

    5

    6

    7

    +-----------+

    | version() |

    +-----------+

    | 8.0.16    |

    +-----------+

    1 row in set (0.00 sec)

     

     

  3. 查看当前默认的密码认证插件:

     

     

    1

    2

    > show variables like 'default_authentication_plugin';

     

     

     

     

    1

    2

    3

    4

    5

    6

    7

    +-------------------------------+-----------------------+

    | Variable_name                 | Value                 |

    +-------------------------------+-----------------------+

    | default_authentication_plugin | caching_sha2_password |

    +-------------------------------+-----------------------+

    1 row in set (0.01 sec)

     

     

  4. 查看当前所有用户绑定的认证插件:

     

     

    1

    2

    > select host,user,plugin from mysql.user;

     

     

     

     

    1

    2

    3

    4

    5

    6

    7

    8

    9

    10

    11

    +-----------+------------------+-----------------------+

    | host      | user             | plugin                |

    +-----------+------------------+-----------------------+

    | %         | root             | caching_sha2_password |

    | localhost | healthchecker    | caching_sha2_password |

    | localhost | mysql.infoschema | caching_sha2_password |

    | localhost | mysql.session    | caching_sha2_password |

    | localhost | mysql.sys        | caching_sha2_password |

    +-----------+------------------+-----------------------+

    5 rows in set (0.00 sec)

     

     

  5. 假如想更改 root 用户的认证方式

     

     

    1

    2

    3

    4

    5

    6

    7

    8

    9

    # 修改加密规则

    > ALTER USER 'root'@'%' IDENTIFIED BY 'root' PASSWORD EXPIRE NEVER;

    # 更新用户密码

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

    # 赋予 root 用户最高权限

    > grant all privileges on *.* to root@'%' with grant option;

    # 刷新权限

    > flush privileges;

     

     

    完成解决方案。
    注意:在这之后,将不再支持以下的权限授予语句:

 

 

1

2

grant all privileges on *.* to root@'%' identified by '123456' with grant option;

 

 

参考资料:

MySQL 8.0报错:error 2059: Authentication plugin ‘caching_sha2_password’ cannot be loaded)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值