![](https://csdnimg.cn/release/download_crawler_static/88815820/bg6.jpg)
mysql> select user,host,password_reuse_history from mysql.user;
#我们尝试修改密码试试
mysql> alter user 'yuhuashi'@'%' identified by 'yuhuashi';
ERROR 3638 (HY000): Cannot use these credentials for 'yuhuashi@%' because
they contradict the password history policy
#上面的这个配置项成功是因为在 mysql 数据库中多了一张 password_history 的表,在
这张表中记录了修改记录。
mysql> select * from mysql.password_history;
#如果我们把这个表 delete 之后,就可以正常修改了,建议不要随便动这个表
password_require_current 变量配置说明
只针对普通用户有效,针对 root 等具有修改 mysql.user 表权限的用户无效
举例说明:
root 账户登录
mysql> alter user 'yuhuashi'@'%' identified by 'mysql';
Query OK, 0 rows affected (0.03 sec)
yuhuashi 账户登录,修改自身密码
mysql> alter user 'yuhuashi1'@'%' identified by 'mysql';
ERROR 3638 (HY000): Cannot use these credentials for 'yuhuashi1@%' because
they contradict the password history policy
mysql> alter user 'yuhuashi1'@'%' identified by 'yuyu' replace 'mysql';
Query OK, 0 rows affected (0.02 se
➢ 角色管理
MySQL8.0 新增了根据角色设置用户权限,如下图所示:
这个特性就相当于 oracle role 的管理,下面举例来说明:
#创建一个名字叫 rw_role 的角色
mysql> create role 'rw_role';
Query OK, 0 rows affected (0.01 sec)
#给这个角色授权,赋予增删改查的权限
mysql> grant select,insert,update,delete on yuhuashi.* to 'rw_role';
Query OK, 0 rows affected (0.08 sec)