Mysql登錄報錯 “Access denied for user 'root'@'localhost' (using password: YES)”


1.環境

CentOS 7.6
Mysql 5.7

2.問題

3.解決方案

1. 關閉Mysql服務

service mysqld stop

2. 使用命令跳過輸入密碼驗證過程

mysqld_safe --skip-grant-tables &

#--skip-grant-tables:跳過授權表,通過此參數來跳過輸入密碼,
# & 表示設置此進程為后台進程

3. 進入Mysql數據庫,通過sql語句修改密碼

  use mysql;
  update user set authentication_string=password("admin") where user = 'root';

  --刷新權限
  flush privileges;

4. 重啟Mysql服務,使用新密碼登錄

 service mysqld restart


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM