MySQL用户密码过期登陆报错ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
今天接到主从复制失败告警,查看MySQL,发现MySQL能够登陆但是执行命令报错,
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.

因为是用户密码过期了
解决办法:
登陆MySQL命令行,执行
set password=password("password");
flush privileges;
#设置用户密码永不过期
ALTER USER 'root'@'localhost' PASSWORD EXPIRE NEVER;
查看用户密码默认过期时间设置,默认360天
mysql> show global variables like "default_password_lifetime";
+---------------------------+-------+
| Variable_name | Value |
+---------------------------+-------+
| default_password_lifetime | |
+---------------------------+-------+
row in set (0.00 sec) 设置用户密码永不过期(临时生效)
mysql> SET GLOBAL default_password_lifetime = ;
Query OK, rows affected (0.00 sec) mysql> show global variables like "default_password_lifetime";
+---------------------------+-------+
| Variable_name | Value |
+---------------------------+-------+
| default_password_lifetime | |
+---------------------------+-------+
row in set (0.00 sec)
如果要设置密码永不过期,设置my.cnf
vi /etc/my.cnf
添加
#设置用户密码永不过期
default_password_lifetime=0 这样重启后也是没问题的
查看用户密码设置
mysql> select user,host,password_expired,password_last_changed,password_lifetime from mysql.user;
+----------------+-----------+------------------+-----------------------+-------------------+
| user | host | password_expired | password_last_changed | password_lifetime |
+----------------+-----------+------------------+-----------------------+-------------------+
| root | localhost | N | -- :: | |
| mysql.sys | localhost | N | -- :: | NULL |
| root | % | N | -- :: | NULL |
| zabbix_monitor | localhost | N | -- :: | NULL |
+----------------+-----------+------------------+-----------------------+-------------------+
rows in set (0.00 sec)
创建一个有效期30天的用户
create user tt@'%' identified by '' password expire interval day; mysql> select user,host,password_expired,password_last_changed,password_lifetime from mysql.user;
+-----------+------------+------------------+-----------------------+-------------------+
| user | host | password_expired | password_last_changed | password_lifetime |
+-----------+------------+------------------+-----------------------+-------------------+
| root | localhost | N | -- :: | NULL |
| mysql.sys | localhost | N | -- :: | NULL |
| mysync | 10.73..% | N | -- :: | NULL |
| tt | % | N | -- :: | |
+-----------+------------+------------------+-----------------------+-------------------+
参考
mysql-5.7 密码过期详解 http://www.mamicode.com/info-detail-2042849.html
Mysql 5.7 账户过期设置 - CSDN博客 http://blog.csdn.net/jc_benben/article/details/77934469
MySQL用户密码过期登陆报错ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.的更多相关文章
- 第一次登录mysql,使用任何命令都报错ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
问题: 使用临时密码登录成功后,使用任何myql命令,例如show databases;都提示下面的报错 ERROR 1820 (HY000): You must reset your passwor ...
- MySQL5.7 报错 ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement
MySQL5.7 报错 : ERROR 1820 (HY000): You must reset your password using ALTER USER statement before exe ...
- mysql5.7初始化密码报错 ERROR 1820 (HY000): You must reset your password using ALTER USER statement before
mysql初始化密码常见报错问题1,mysql5.6是密码为空直接进入数据库的,但是mysql5.7就需要初始密码 cat /var/log/mysqld.log | grep password1 2 ...
- mysql5.7初始化密码报错 ERROR 1820 (HY000): You must reset your password using ALTER USER statement
mysql初始化密码常见报错问题 1,mysql5.6是密码为空直接进入数据库的,但是mysql5.7就需要初始密码 cat /var/log/mysqld.log | grep password 2 ...
- mysql 报错ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executin
解决办法1. 修改用户密码mysql> alter user 'root'@'localhost' identified by 'youpassword'; 或者 mysql> set p ...
- MySQL数据库使用报错ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
今天MySQL数据库,在使用的过程中一直报错ERROR 1820 (HY000): You must reset your password using ALTER USER statement be ...
- MySQL root账户密码设为“root”后执行命令提示ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
修改root账户密码为“root”后,提示ERROR 1820 (HY000): You must reset your password using ALTER USER statement bef ...
- MySQL:ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
解决方法: 修改密码:alter user 'root'@'localhost' identified by '123456'; mysql> use mysql; ERROR 1820 (HY ...
- 【MySQL】ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing
今天上午遇到了一个问题,新创建的mysql5.7的数据库,由于初始化有点问题,没有给root密码,用了免密码登录. 但是,修改了root密码之后,把配置中的免密登录的配置注释掉后,重启服务.服务正常启 ...
随机推荐
- 使用Arduino驱动基于ST7533芯片的TFT屏
在合宙通信买了一个1.8寸的TFT屏,驱动芯片是ST7533,本来打算使用Air800直接驱动,但由于其他原因,放弃了.于是尝试使用arduino驱动,为了屏幕刷新速度更快,采用硬件SPI. 硬件连接 ...
- 11th 回忆整个学期——告学弟学妹
告诉后来的学弟学妹,不要因为艰难而却步,坚持下去才知道,山的对面是什么.很多东西或许一开始看起来是无用,甚至无意义的,但是努力去做,你才知道价值所在.不要等一切结束了,才懂得自己错过了什么.
- Windows10 版本说明 From wiki 20190104
Windows版本说明 文字版本的: PC版本历史[编辑] 索引: 旧版本 旧版本,受支援 最新版本 最新预览版本 Version 1507(Windo ...
- python自动化之爬虫模拟登录
http://selenium-python.readthedocs.io/locating-elements.html ####################################### ...
- 【刷题】LOJ 6005 「网络流 24 题」最长递增子序列
题目描述 给定正整数序列 \(x_1 \sim x_n\) ,以下递增子序列均为非严格递增. 计算其最长递增子序列的长度 \(s\) . 计算从给定的序列中最多可取出多少个长度为 \(s\) 的递增子 ...
- 学习笔记(two sat)
关于two sat算法 两篇很好的论文由对称性解2-SAT问题(伍昱), 赵爽 2-sat解法浅析(pdf). 一些题目的题解 poj 3207 poj 3678 poj 3683 poj 3648 ...
- Markdown公式(二)
参考资料https://gavin_nicholas.coding.me/archives/ 1. 如何输入括号和分隔符 () . [] 和 | 表示自己, {} 表示 {} .当要显示大号的括号或分 ...
- redirect和forward的区别
异同 1.从地址栏显示来说 forward是服务器请求资源,服务器直接访问目标地址的URL,把那个URL的响应内容读取过来,然后把这些内容再发给浏览器.浏览器根本不知道服务器发送的内容从哪里来的,所以 ...
- c++桥接模式
可以简记为pointer to implement:”指向实现的指针”. [DP]书上定义:将抽象部分与它的实现部分分离,使它们都可以独立地变化.考虑装操作系统,有多种配置的计算机,同样也有多款操作系 ...
- NameError: name 'reload' is not defined
对于 Python 2.X: import sys reload(sys) sys.setdefaultencoding("utf-8") 对于 <= Python 3.3: ...