今天接到主从复制失败告警,查看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.的更多相关文章

  1. 第一次登录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 ...

  2. 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 ...

  3. 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 ...

  4. 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 ...

  5. 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 ...

  6. 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 ...

  7. 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 ...

  8. 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 ...

  9. 【MySQL】ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing

    今天上午遇到了一个问题,新创建的mysql5.7的数据库,由于初始化有点问题,没有给root密码,用了免密码登录. 但是,修改了root密码之后,把配置中的免密登录的配置注释掉后,重启服务.服务正常启 ...

随机推荐

  1. idea 使用 mybaits generator

    Intellij IDEA 14 作为JavaIDE 神器,接触后发现,非常好用,对它爱不释手,打算离开eclipse和myeclipse,投入Intellij IDEA的怀抱. 然而在使用的过程中会 ...

  2. HTTP协议(1)

    HTTP 协议笔记 1. HTTP 传输机制 HTTP 是一个应用层协议,位于 TCP 的层次之上,并且是基于 TCP 协议进行通信的,也就是说 HTTP 在每一次通信之前都要先建立 TCP 连接来保 ...

  3. 侧边导航栏css示例

    效果展示: html: <div class="sidebar"> <ul> <li>优先级 <ul> <li>< ...

  4. [转帖][Bash Shell] Shell学习笔记

    [Bash Shell] Shell学习笔记 http://www.cnblogs.com/maybe2030/p/5022595.html  阅读目录 编译型语言 解释型语言 5.1 作为可执行程序 ...

  5. python接口自动化感悟

    一个方法对应一个接口,每个方法都要有登陆 成一个独立的逻辑功能块

  6. c++ std::function

    std::function 是一个模板类,用于封装各种类似于函数这样的对象,例如普通函数,仿函数,匿名函数等等.其强大的多态能力,让其使用只依赖于调用特征.在程序的升级中,可以实现一个调用表,以兼容新 ...

  7. MT【99】2005联赛二试题我的一行解法

    为表示尊敬先展示参考答案:参考答案其实很好的体现了当年出题人陶平生的想法,就是利用已知形式联想到三角里的射影定理,从而写出余弦定理形式,利用三角解题,如下: 这里展示以下几年前做这题时我的解法: $\ ...

  8. Mac中把光盘转存为iso文件

    因为Mac是类Unix的,因此,dd命令同样适用于Mac,那么,就很简单了,复习一下dd的用法而已 [xiaosilent@rmbp Volumes]$ drutil status Vendor Pr ...

  9. Oracle数据库--PL/SQL存储过程和函数的建立和调用

    1.存储过程建立的格式: create or replace procedure My_Procedure is begin --执行部分(函数内容); end; / 例子:(以hr表为例) crea ...

  10. POJ 1511 Invitation Cards / UVA 721 Invitation Cards / SPOJ Invitation / UVAlive Invitation Cards / SCU 1132 Invitation Cards / ZOJ 2008 Invitation Cards / HDU 1535 (图论,最短路径)

    POJ 1511 Invitation Cards / UVA 721 Invitation Cards / SPOJ Invitation / UVAlive Invitation Cards / ...