mysql密碼過期問題解決方案
- 問題再現:密碼過期
舊電腦許久沒有用,今天打開發現數據庫連接不上了。提示密碼過期,請修改密碼。
ERROR 1862 (HY000): Your password has expired. To log in you must
change it using a client that supports expired passwords.
- 解決方案:修改密碼
- cmd切換至mysql bin目錄下
- 啓動mysql服務:net mysql start
- 以root權限登錄mysql:(這裏我的賬戶是root,密碼是123)mysql -uroot -p123
- 更改密碼:SET PASSWORD = PASSWORD(‘root’);
- 問題拓展:重置密碼
有些同學可能記不得原密碼是什麼,我們可以先重置密碼,再進行上面的方案。重置密碼的步奏如下
1. 找到mysql配置文件my.ini,在配置文件下添加一行:
skip_grant_tables
2. 重啓mysql服務
3. 修改mysql中root用戶的權限:
update user set password=password("123456") where user="root";
請注意:mysql 5.7 忘記密碼,及修改密碼問題,密碼列不再是Password ,而是authentication_string。如下:
update user set authentication_string=password("123456") where user="root";
4. 去除mysql配置文件中的skip_grant_tables語句
5. 重啓mysql服務