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密码之后,把配置中的免密登录的配置注释掉后,重启服务.服务正常启 ...
随机推荐
- Leetcode——30.与所有单词相关联的字串【##】
@author: ZZQ @software: PyCharm @file: leetcode30_findSubstring.py @time: 2018/11/20 19:14 题目要求: 给定一 ...
- Leetcode——37.解数独 [##]
@author: ZZQ @software: PyCharm @file: leetcode37_solveSudoku.py @time: 2018/11/20 16:41 思路:递归回溯 首先, ...
- 【助教】浅析log4j的使用
有不少童鞋私信我一些在写代码时候遇到的问题,但是无法定位问题出在哪里,也没有日志记录,实际上,写日志是开发项目过程中很重要的一个环节,很多问题都可以从日志中找到根源,从而定位到出错位置,为解决问题提供 ...
- iOS国际化——通过脚本使storyboard翻译自增
一. 针对两种文件的国际化处理 代码中即.m文件的国际化 首先在你需要进行国际化处理的字符串外面加一层NSLocalizedString,注意中文也是可以的哦 textfield.text = [NS ...
- C#简述(三)
详细请参考:http://www.runoob.com/csharp/csharp-string.html 1.C# 字符串(String) 在 C# 中,可以使用字符数组来表示字符串,但是,更常见的 ...
- ehlib使用内存表的方法
ehlib提供了一个TMemTableEh控件,这个控件不需要连接数据库就可以在ehlib中显示数据,在做一些虚的表格时比较有用. 简单的使用主要有这几个步骤: 1.添加量过控件Tdatasource ...
- Zoom 会议系统
Jfrog的培训过程中 发现ppt的效果很不理想 讲师使用zoom的方式效果很好 首先说一下 zoom的定价体系 官网信息: https://www.zoom.us/profile 好像必须使用 企 ...
- wordpress WP-PageNavi分页
1.安装WP-PageNavi分页插件: 这个就没什么好介绍直接安装插件. 2.在需要分页的页面按下面的方式加上相应代码: 插入的位置在以 <?php if (have_posts()) : ? ...
- #35 string(缩点+动态规划)
容易发现有了交换相邻字符的操作后,只要字符串所含有的字符种类和数量相同其就是等价的.这样的状态只有n^3级别,将其抽象成点子串变换抽象成边后就是求最长路径了,缩点dp解决. 码量巨大,不是很明白要怎样 ...
- SPOJ DQUERY - D-query (莫队算法|主席树|离线树状数组)
DQUERY - D-query Given a sequence of n numbers a1, a2, ..., an and a number of d-queries. A d-query ...