mysql 8.0 的用户认证方式 caching_sha2_password、mysql_native_password

新安装mysql 8.0,在用户登录时提示这样的错误

Failed to connect to MySQL server: Authentication plugin 'caching_sha2_password' cannot be loaded: /usr/lib64/xtrabackup/plugin/caching_sha2_password.so: cannot open shared object file: No such file or directory.

在网上搜了下,发现主要是因为mysql 8.0的默认认证方式有了调整,可以选择不同的plugin。

ALTER USER 'root'@'localhost' IDENTIFIED BY 'password' PASSWORD EXPIRE NEVER; 
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password'; 
FLUSH PRIVILEGES; 

修改默认认证方式

默认的认证方式是 caching_sha2_password

mysql> show global variables like '%default_auth%';
+-------------------------------+-----------------------+
| Variable_name                 | Value                 |
+-------------------------------+-----------------------+
| default_authentication_plugin | caching_sha2_password |
+-------------------------------+-----------------------+
1 row in set (0.00 sec)

修改

# vi /etc/my.cnf

[mysqld]
default_authentication_plugin = mysql_native_password

修改已有用户的认证方式


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

mysql> alter user 'root'@'192.168.56.%' identified with mysql_native_password by 'MyNewPass@123' PASSWORD EXPIRE NEVER;
Query OK, 0 rows affected (0.39 sec)

直接修改


mysql> alter user 'root'@'192.168.56.%' identified with mysql_native_password by 'MyNewPass@123' PASSWORD EXPIRE NEVER;
Query OK, 0 rows affected (0.39 sec)

caching_sha2_password、mysql_native_password

下面的问题源自mysql 官方文档
Important
In MySQL 8.0, caching_sha2_password is the default authentication plugin rather than mysql_native_password. For information about the implications of this change for server operation and compatibility of the server with clients and connectors, see caching_sha2_password as the Preferred Authentication Plugin.

参考:
https://dev.mysql.com/doc/refman/8.0/en/caching-sha2-pluggable-authentication.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

数据库人生

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值