1. 程式人生 > >mysql5.7的初始化後密碼找回

mysql5.7的初始化後密碼找回

1 通過日誌檔案中給出的預設密碼 grep password /var/log/mysqld.log
2 日誌檔案發生意外後,vim /etc/my.cnf 新增skip-grant-tables=1 或者skip-grant-tables 儲存後重啟資料庫服務
mysql -uroot 即可進入資料庫服務了
連線mysql庫 use mysql;
更新user表中的root使用者密碼 update user set authentication_string=password(‘wang1.1’) where user=‘root’;
flush privileges;
後退出 刪除my.cnf中新增的 skip-grant-tables 即完成密碼的更換

alter user ‘root’@‘localhost’ identified by ‘新密碼’;
密碼簡單格式
mysql> set global validate_password_policy=0;
set global validate_password_length=1; 原始的8位改成1位