MYSQL8.0修改密码的一些疑问

mysql安装以后,默认密码为空,可以使用

mysqld --initial

Mysql 提供了两种基于SHA-256的密码验证的插件:

sha256_password  基于基本的sha-256 验证
caching_sha2_password Implements SHA-256 authentication (like sha256_password), but uses caching on the server side for better performance and has additional features for wider applicability.

查看mysql使用的密码插件:

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

那么修改密码的时候,我们就要这样:

  alter user 'root'@'localhost' identified with caching_sha2_password by 'your_new_password';  

如果你的root密码原来是空密码,那么使用select语句查看:

mysql> select authentication_string from user;
+------------------------------------------------------------------------+
| authentication_string                                                  |
+------------------------------------------------------------------------+
| $A$005$THISISACOMBINATIONOFINVALIDSALTANDPASSWORDTHATMUSTNEVERBRBEUSED |
| $A$005$THISISACOMBINATIONOFINVALIDSALTANDPASSWORDTHATMUSTNEVERBRBEUSED |
| $A$005$THISISACOMBINATIONOFINVALIDSALTANDPASSWORDTHATMUSTNEVERBRBEUSED |
| $A$005$4<+yQ2yNzb+L{TFc{T.xxxoMky8g1F0KbCQeyHOZ8JSO/NWydKhRGnhCVxyn/ |
+------------------------------------------------------------------------+
5 rows in set (0.00 sec)

就变成了有密码...
然后使用新密码登陆mysql,发现已经成功了。

上一篇:入门6数据缓存


下一篇:asp.net代码练习 work084 使用Cache的示例