登錄MySQL的root用戶提示密碼過期:

解決方案如下:
- 首先將my.cnf中加入在[mysqld]節點上加skip-grant-tables,作用是:跳過表中的驗證,可以無密碼
![]()
- 重啟服務:

- 這時就可以直接用mysql -u root登錄數據庫:

- 執行修改密碼語句:
1 alter user 'root'@'localhost' identified by 'mysql1';
提示:The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement,大致意思是:服務器使用--skip grant tables選項運行,因此無法執行此語句

解決辦法就是刷新權限:
![]()
再次執行修改密碼的sql語句:

- 修改成功之后,記得再次刷新權限:

- 此時密碼已經修改完畢,千萬記得把my.cnf中的skip-grant-tables去掉:
去掉之后就會提示沒有密碼不能登錄:
![]()
按照用戶名沒密碼的格式登錄成功:

