【mysql】You must reset your password using ALTER USER statement before executing this statement.


故障现场:登陆到MySQL服务器,不管你执行什么命令都报这个错

mysql> show databases;
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
mysql> use test;
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
...
...

怎么会这样呢?难道我进的是假服务器?

原因分析:这个主要是由一个参数控制的 default_password_lifetime,看看官方的解释

【mysql】You must reset your password using ALTER USER statement before executing this statement._第1张图片

仔细看哈,Note信息有时候比上面的信息有用(英文的note我一般都是忽略的,有可能你忽略掉的那部分对性能也有帮助哦)

问题解决:在开源的世界里,我们不怕报错,有报错才有解决思路。下面来看下自己环境里的

mysql> select version();
+--------------+
| version()    |
+--------------+
| 5.7.10-3-log |
+--------------+
1 row in set (0.01 sec)

mysql> show variables like 'default_password_lifetime';
+---------------------------+-------+
| Variable_name             | Value |
+---------------------------+-------+
| default_password_lifetime | 360     |
+---------------------------+-------+
1 row in set (0.00 sec)


soga,原来如此。那么就修改密码呗

alter user user() identified by "123456";


问题得到成功解决!当前用户可以成功执行权限内的命令。


你可能感兴趣的:(服务器,不能登录,密码过期,statement,解决方案)