1. 程式人生 > 資料庫 >mysql(Linux)忘記密碼

mysql(Linux)忘記密碼

修改MySQL的登入設定

vi /etc/my.cnf 

在[mysqld]的段中加上一句:skip-grant-tables

skip-grant-tables

重啟mysql服務

service mysqld restart

登入mysql

mysql -u root

修改祕密

alter user 'root'@'localhost' identified by 'xuebaqiang'; 

錯誤解決

ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
ERROR 1819 (HY000): Your password does not satisfy the current policy requirements

設定驗證密碼長度

set global validate_password_length=4;

設定密碼驗證策略【預設等級為MEDIUM(中等),可通過以下命令修改為LOW(低)】

set global validate_password_policy=0;

修改密碼

alter user user() identified by "1234";