Access denied for user 'root'@'localhost' (using password:YES)解決方法


https://www.cnblogs.com/da19951208/p/6403783.html?utm_source=itdadao&utm_medium=referral

 

在MySQL的使用過程中,我們可能會碰到“Access denied for user 'root'@'localhost' (using password:YES)”的問題,那么接下來我們就來解決它。

  經過我的百度查詢最后得出結論:出現這種錯誤有兩種可能,一是MySQL的root用戶的密碼錯誤,二是權限不夠的問題。通常解決辦法是修改密碼。。。

  由於我使用的是Windows系統,所以方法也是Windows系統的修改方法:

  1、開始 → 搜索欄里面輸入cmd → 右鍵cmd.exe選擇以管理員的身份運行(亦可以在C:\Windows\System32目錄下找到這個cmd.exe,右鍵,以管理員身份運行)

  2、輸入net stop mysql停止MySQL服務

  3、輸入命令行來到mysql的bin目錄下,輸入下列粗體命令

  D:\MySQL\bin>mysqld  --defaults-file="D:\MySQL\my.ini" --console --skip-grant-tables

  等一下,顯示出以下結果說明MySQL啟動:

  170215 22:26:09 [Warning] The syntax '--log' is deprecated and will be removed  inMySQL 7.0. Please use '--general_log'/'--general_log_file' instead.
  170215 22:26:09 [Warning] The syntax '--log_slow_queries' is deprecated and will be removed in MySQL 7.0. Please use '--slow_query_log'/'--  slow_query_log_file' instead.
  170215 22:26:09 [Warning] The syntax '--log' is deprecated and will be removed in MySQL 7.0. Please use '--general_log'/'--general_log_file' instead.
  170215 22:26:09 [Warning] The syntax '--log_slow_queries' is deprecated and will be removed in MySQL 7.0. Please use '--slow_query_log'/'--slow_query_log_file' instead.
  170215 22:26:09 [ERROR] The update log is no longer supported by MySQL in version 5.0 and above. It is replaced by the binary log. Now starting MySQL with --log-bin='' instead.
  170215 22:26:09  InnoDB: Started; log sequence number 0 324221
  170215 22:26:09 [Note] mysqld: ready for connections.Version: '5.1.33-community-log'  socket: ''  port: 3306  MySQL Community Server (GPL)

  4、再以管理員的身份打開一個cmd.exe,輸入命令行來到mysql的bin目錄下,輸入:mysql -uroot mysql

  5、進入mysql之后,輸入命令行修改密碼:

  mysql>update user set authentication_string=password('123456') where user='root';

  6、刷新權限:mysql>flush privileges;

  7、退出mysql:mysql> quit;

  8、關閉MySQL:D:\MySQL\bin>mysqladmin shutdown(出現錯誤,則:mysqladmin -uroot -p shutdown 然后輸入新密碼)

  9、至此修改密碼完成,可以輸入命令行:net start mysql 啟動MySQL服務,mysql -uroot -p ,輸入密碼就可以進入mysql了。


免責聲明!

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



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