天天看點

MySQL5.7出現Your password has expired. To log in you must change it using a client that supports expir

今天晚上本來想寫bootstrap-fileinput插件內建fastdfs的文章,但是剛啟動idea裡面的QiYuAdmin就出現了錯誤: 

Your password has expired. To log in you must change it using a client that supports expired passwords.其實隻需要修改密碼就可以了,這個問題我找到了以下解決辦法:

1、修改 /etc/my.cnf,在 [mysqld] 小節下添加一行:skip-grant-tables=1

這一行配置讓 mysqld 啟動時不對密碼進行驗證

2、重新開機 mysqld 服務:systemctl restart mysqld

3、使用 root 使用者登入到 mysql:mysql -u root

4、切換到mysql資料庫,更新 user 表:

update mysql.user set authentication_string=password(‘root’) where user=’root’ and Host = ‘localhost’;

flush privileges;

在之前的版本中,密碼字段的字段名是 password,5.7版本改為了 authentication_string

5、退出 mysql,編輯 /etc/my.cnf 檔案,删除 skip-grant-tables=1 的内容

6、重新開機 mysqld 服務,再用新密碼登入。但此時還是不行哦,我以為可以了,就沒有往下看了。其實還有最後一步。

7、alter user ‘root’@’localhost’ identified by ‘root’;

有個疑問,不知道為什麼程式是一直連結不上的,但是用戶端,比如Navcat和MySQL的WorkBench都是可以連結上的?最後一段我是直接在Navcat裡面執行的