MySQL加密方式之更改(error 1251)

caching_sha2_password To mysql_native_password

MySQL V8后,采用更强的SHA加密方式,caching_sha2_password。如果客户端、JDBC或者App通过mysql_native_password方式加密,在认证的过程中会出现如下错误所示:error 1251 [Client does not support authentication protocol requested by server; consider upgrading MySQL client]。

解决方案,在服务器端更改加密和解密方式如下:

  1. 修改权限
mysql> ALTER USER 'root'@'%' IDENTIFIED BY 'root' PASSWORD EXPIRE NEVER;
Query OK, 0 rows affected (0.01 sec)
  1. 修改加密方式
mysql> ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY 'root';
Query OK, 0 rows affected (0.01 sec)

或者

If MySQL is already installed with the new authentication method, you may switch to the Legacy method as described below. Open my.ini in C:\ProgramData\MySQL\MySQL Server 8.0\ and find the following line:

default_authentication_plugin=caching_sha2_password

Change the values of the parameter:

default_authentication_plugin=mysql_native_password

Next, change the authentication type for the user, under which you are connecting to the database. Open ‘Command Line Client’ and run the following command:

ALTER USER 'username'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password';

  1. 写入生效
mysql> flush privileges;
Query OK, 0 rows affected (0.01 sec)
  1. root字符加密前后的变化
*81F5E21E35407D884A6CD4A731AEBFB6AF209E1B

$A$005$zxW(&Y?ibV=G["LH%h3198Lz1JpYixMup7Oq2fHzpK6WDIfThHMiJhCj3HC8
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值