1. 程式人生 > >mysql密碼忘記,提示修改密碼

mysql密碼忘記,提示修改密碼

#1.停止mysql資料庫 /etc/init.d/mysqld   stop   #2.執行如下命令 mysqld_safe --user=mysql --skip-grant-tables --skip-networking &   #3.使用root登入mysql資料庫 mysql -u root mysql   #4.更新root密碼 mysql> UPDATE user SET Password=PASSWORD(
'newpassword' ) where USER= 'root' ; #最新版MySQL請採用如下SQL: mysql> UPDATE user SET authentication_string=PASSWORD( 'newpassword' ) where USER= 'root' ;   #5.重新整理許可權  mysql> FLUSH PRIVILEGES;  
#6.退出mysql mysql> quit   #7.重啟mysql /etc/init.d/mysqld   restart   #8.使用root使用者重新登入mysql mysql -uroot -p  Enter password: <輸入新設的密碼newpassword>



ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
mysql> SET PASSWORD = PASSWORD('123456');   //123456 是重置的新密碼 以上操作後又遇到新問題: ERROR 1819 (HY000): Your password does NOT satisfy the CURRENT policy requirements。 應該是密碼過於簡單了。 後來用大寫字母+數字+特殊字元混合了一個密碼。重置密碼成功! 以後操作,沒有再出現上述問題。

注意:如果只想設定簡單密碼需要修改兩個全域性引數: mysql> set global validate_password_policy=0; mysql> set global validate_password_length=1;