ERROR 1820 (HY000): You must reset your password using ALTER USER statement
mysql执行语句报错mysql> use mysql;ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.mysql> show databases;ERROR 1820 (HY000): You must reset y
mysql执行语句报错
mysql> use mysql;
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
mysql> show databases;
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
提示要用ALTER USER修改密码才可以 但是如果想要设置非常简单的密码,比如123456会提示密码不符合要求
mysql> alter user 'root'@'localhost' identified by '123456';
ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
/ / 但是修改这个参数会报错,没有这个系统变量
mysql> set global validate_password_policy=0;
ERROR 1193 (HY000): Unknown system variable 'validate_password_policy'
添加参数
这个时候就得去修改一下mysql的配置文件
[root@zheng ~]# vi /etc/my.cnf
[mysqld] ## 在mysqld文本段里添加这两行
#添加密码验证插件
plugin-load-add=validate_password.so
#服务器在启动时加载插件,并防止在服务器运行时删除插件
validate-password=FORCE_PLUS_PERMANENT
"/etc/my.cnf" 34L, 1167C written
[root@zheng ~]# systemctl restart mysqld / / 修改完重启mysql
[root@zheng ~]# mysql -uroot -p
Enter password: 密码123
修改参数值
修改validate_password_policy参数的值
validate_password_length(密码长度)参数默认为8,我们修改为1
mysql> set global validate_password_policy=0;
Query OK, 0 rows affected (0.00 sec)
mysql> set global validate_password_length=1;
Query OK, 0 rows affected (0.00 sec)
mysql> alter user 'root'@'localhost' identified by '123456';
Query OK, 0 rows affected (0.00 sec)
mysql安装成功
mysql> show databases; / / 这里就可以正常使用了
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
+--------------------+
4 rows in set (0.00 sec)
这里说一下,我这用的是5.7版本的,mysql8.0是不支持这么修改的
mysql> status
--------------
mysql Ver 14.14 Distrib 5.7.30, for Linux (x86_64) using EditLine wrapper
Connection id: 5
Current database:
Current user: root@localhost
SSL: Not in use
Current pager: stdout
Using outfile: ''
Using delimiter: ;
Server version: 5.7.30
Protocol version: 10
Connection: Localhost via UNIX socket
Server characterset: latin1
Db characterset: latin1
Client characterset: utf8
Conn. characterset: utf8
UNIX socket: /var/lib/mysql/mysql.sock
Uptime: 1 hour 58 min 34 sec
Threads: 1 Questions: 26 Slow queries: 0 Opens: 106 Flush tables: 1 Open tables: 99 Queries per second avg: 0.00
8.0mysql版本修改参数设置
mysql> set global validate_password.policy=0;
mysql> set global validate_password.length=1;
————————————————
版权声明:本文为CSDN博主「平平无奇子」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/qq_44792624/article/details/107426590
更多推荐
所有评论(0)