1. 程式人生 > >【mysql】You must reset your password using ALTER USER statement before executing this statement.

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

故障現場:登陸到MySQL伺服器,不管你執行什麼命令都報這個錯

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

怎麼會這樣呢?難道我進的是假伺服器? 發火

原因分析:這個主要是由一個引數控制的 default_password_lifetime,看看官方的解釋


仔細看哈,Note資訊有時候比上面的資訊有用(英文的note我一般都是忽略的,有可能你忽略掉的那部分對效能也有幫助哦)

問題解決:在開源的世界裡,我們不怕報錯,有報錯才有解決思路。下面來看下自己環境裡的

  1. mysql> select version();
  2. +--------------+
  3. | version() |
  4. +--------------+
  5. | 5.7.10-3-log |
  6. +--------------+
  7. 1 row in set (0.01 sec)
  8. mysql> show variables like 'default_password_lifetime';
  9. +---------------------------+-------+
  10. | Variable_name | Value |
  11. +---------------------------+-------+
  12. | default_password_lifetime | 360 |
  13. +---------------------------+-------+
  14. 1 row in set (0.00 sec)


soga,原來如此。那麼就修改密碼唄

alter user user() identified by "123456";