首页 技术 正文
技术 2022年11月6日
0 收藏 785 点赞 319 浏览 2230 个字

MySQL8 修改密码验证插件

查看当前用户使用的密码验证插件

mysql> show variables like '%auth%';
+-------------------------------+-----------------------+
| Variable_name | Value |
+-------------------------------+-----------------------+
| default_authentication_plugin | caching_sha2_password |
+-------------------------------+-----------------------+

查看 MySQL8 支持的密码验证插件

mysql> show plugins;
+----------------------------+----------+--------------------+---------+---------+
| Name | Status | Type | Library | License |
+----------------------------+----------+--------------------+---------+---------+
| binlog | ACTIVE | STORAGE ENGINE | NULL | GPL |
| mysql_native_password | ACTIVE | AUTHENTICATION | NULL | GPL |
| sha256_password | ACTIVE | AUTHENTICATION | NULL | GPL |
| caching_sha2_password | ACTIVE | AUTHENTICATION | NULL | GPL |
| sha2_cache_cleaner | ACTIVE | AUDIT | NULL | GPL |
| CSV | ACTIVE | STORAGE ENGINE | NULL | GPL |

修改用户的密码验证插件

mysql> alter user 'root'@'localhost' identified with mysql_native_password by 'root';
Query OK, 0 rows affected (0.45 sec)

修改系统默认的密码验证插件

  1. 配置参数方式 default-authentication-plugin
# 设置默认密码验证插件
default-authentication-plugin=caching_sha2_password
  1. 启动参数方式 --default-authentication-plugin
C:\Users\jie>D:\chengxu\MySQL\mysql-8.0.12-winx64\bin\mysqld --default-authentication-plugin=mysql_native_password

bugs

如果只指定用户名不指定主机,则表示的用户是任意主机,即 ‘username’@’%’,这个和本地主机即 ‘username’@’localhost’ 的含义是不同的。

# 'root' 更改失败,因为表示的是 'root'@'%',而此处用户只有'root'@'localhost'
mysql> alter user 'root' identified with mysql_native_password by 'root';
ERROR 1396 (HY000): Operation ALTER USER failed for 'root'@'%'mysql> select host, user, plugin from mysql.user;
+-----------+------------------+-----------------------+
| host | user | plugin |
+-----------+------------------+-----------------------+
| localhost | caocao | caching_sha2_password |
| localhost | liubei | caching_sha2_password |
| localhost | mysql.infoschema | caching_sha2_password |
| localhost | mysql.session | caching_sha2_password |
| localhost | mysql.sys | caching_sha2_password |
| localhost | root | caching_sha2_password |
+-----------+------------------+-----------------------+

无法通过命令行方式设置默认的密码验证插件

mysql> set default_authentication_plugin=mysql_native_password;
ERROR 1238 (HY000): Variable 'default_authentication_plugin' is a read only variable
mysql> set global default_authentication_plugin=mysql_native_password;
ERROR 1238 (HY000): Variable 'default_authentication_plugin' is a read only variable
相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:8,912
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,436
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,251
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,063
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,694
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,732