1. 程式人生 > >如何解決MySQL 5.7 Access denied for user 'root'@'localhost' (using password YES)問題?

如何解決MySQL 5.7 Access denied for user 'root'@'localhost' (using password YES)問題?

歡迎轉載,轉載請註明出處,謝謝~(作者:喝酒不騎馬 Colton_Null)

from CSDN

最近,在CentOS 6.8上使用MySQL時,無法登入資料庫,並提示Access denied for user ‘root’@’localhost’ (using password:YES)
經過查閱大量資料,現總結一下可用的解決方法

1.首先關閉MySQL服務

[root@localhost /]# service mysqld stop

2.安全啟動MySQL(跳過密碼驗證)

[root@localhost /]# /usr/bin/mysqld_safe --skip-grant-tables

這時候會報

mysqld_safe Logging to '/var/lib/mysql/iZ23dq2wm0jZ.err'.
mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql

我用SecureCRT連線的Linux,到這時候就卡住了,ctrl + c也不能退出。後來找到解決方法:卡住時,在用SecureCRT開啟一個新的連線到系統上繼續操作就可以了。

3.登入MySQL

[root@localhost /]#  mysql -u root

4.更改密碼

mysql> grant all
privileges on *.* to 'root'@'localhost' identified by '123465' with grant option;

其中’root’@’localhost’ 是使用者名稱
第二個’123465’是新密碼

如果此處報錯The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement
則說明沒有寫入許可權,這時候就要關閉資料庫只讀屬性

mysql> set global read_only=0;// 關掉資料庫的只讀屬性
mysql>flush privileges;// 重新整理配置

之後,再執行修改密碼操作
最後,可以再將屬性設定回初始狀態

mysql> set global read_only=1;// 關掉資料庫的只讀屬性
mysql>flush privileges;// 重新整理配置

5.重啟資料庫

[root@localhost /]# service mysqld restart

這時候,就可以用剛才設定的新密碼123465登入資料庫了。問題解決。

相關推薦

如何解決MySQL 5.7 Access denied for user 'root'@'localhost' (using password YES)問題?

歡迎轉載,轉載請註明出處,謝謝~(作者:喝酒不騎馬 Colton_Null) from CSDN 最近,在CentOS 6.8上使用MySQL時,無法登入資料庫,並提示Access denied for user ‘root’@’localhost’

MYSQL登陸異常---Access denied for user 'root'@'localhost' (using password:YES)

發生環境: 部署系統:windows10 mysql:5.7 開發環境,eclipse使用jdbc連線mysql資料庫時,發生該異常。 解決方案: 開啟MySQL目錄下的my.ini檔案,在檔案的最後新增一行“skip-grant-tables”,儲存並關閉檔案

mysql 安裝問題 access denied for user 'root'@'localhost' using password yes/no

           對於MySQL資料庫的安裝,網上有很多教程,但是有很多時候對著教程安裝還是會安裝不成功。之前使用SqlServer也是這樣,這次安裝MySQL出現的主要問題就是網上流傳的安裝教程中最後的注意事項中提到的,如下 注意事項 設定完畢,按“Fini

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

如果過你都試過了,還沒解決,請直接看最下邊  1.開啟MySQL目錄下的my.ini檔案,在檔案的最後新增一行“skip-grant-tables”,儲存並關閉檔案; 2.重啟MySQL服務; 3.通過cmd行進入MySQL的bin目錄,輸入“mysql -u root

MySQL常見問題之——Access denied for user 'root'@'localhost' (using password:YES)解決方法

由於我使用的是Windows系統,所以方法也是Windows系統的修改方法:   1、開始 → 搜尋欄裡面輸入cmd → 右鍵cmd.exe選擇以管理員的身份執行(亦可以在C:\Windows\System32目錄下找到這個cmd.exe,右鍵,以管理員身份執行)   2

Linux連線mysql報錯:Access denied for userroot’@‘localhost’(using password: YES)的解決方法以及忘記密碼

最近在騰訊雲上買了一伺服器玩想,然後為服務配置好mysql mysql -uroot -pxxx 要進入發現報錯 Linux連線mysql報錯:Access denied for user ‘root’@‘localhost’(using password: YES)的解決方法 因為第一次遇

解決MySQL 報錯:1045- Access denied for user 'root'@'localhost'(using password YES)

一、前言 今年瘋狂迷上了開源,只要看到好的開源專案,就會不顧一切一股腦扎進去研究,五一期間發現一個很好的關於眾籌的開源專案,但不巧,這個專案竟然是 PHP 寫的,沒學過 PHP,自然對這個開源專案毫無頭緒了,但我竟然為了這個專案,毅然決定入坑 PHP,

連線mysql出現Access denied for userroot’@’localhost’ (using password:YES)問題解決辦法

網上好多寫的都是很雜七雜八的,直接像我這麼做實際上就可以了,別想太複雜。 原因是root帳戶預設不開放遠端訪問許可權,所以需要修改一下相關許可權。 解決方案: 1.開啟MySQL目錄(我的是在C:\Program Files (x86)\MySQL\MySQL

MYSQL問題解決方案:Access denied for user 'root'@'localhost' (using password:YES)(親測解決)

開發Web專案時,連線MySQL資料庫,出現問題 經查詢資料發現是root帳戶預設不開放遠端訪問許可權,所以需要修改一下相關許可權。 解決方案: 1.開啟MySQL目錄下的my.ini檔案,在檔案的最後新增一行 skip-grant-tables ,儲存

1045 access denied for user 'root'@'localhost' using password yes 以及Can't connect to MySQL解決方法(簡單方法)

昨天還可以連結,今天突然無法訪問資料庫,經過嘗試發現了原因 在網上搜了很多方法,似乎都很麻煩,最後找到了解決方法,我的是mysql 5.7  導致這種情況發生的原因是:mysql服務未啟動 解決方法如下: 開始-->控制面板-->管理工具-->服務--&g

MySQL報錯:java.sql.SQLException: Access denied for user 'root'@'localhost' (using password: YES)

1、使用者名稱密碼錯誤 開啟命令視窗,進入MySQL的bin目錄,一般是在C:\Program Files\MySQL\MySQL Server 5.7\bin,輸入命令: mysql -u [username] -p 如果能進不去,則是使用者名稱密碼錯誤。如果能進

MYSQL重置密碼 MySQL ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password:YES)

一般這個錯誤是由密碼錯誤引起,解決的辦法自然就是重置密碼。 假設我們使用的是root賬戶。 1.重置密碼的第一步就是跳過MySQL的密碼認證過程,方法如下: #vim /etc/my.cnf(注:windows下修改的是my.ini) 在文件內搜尋mysqld定位

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

開啟my.ini檔案,在檔案的最後新增一行 skip-grant-tables ,儲存檔案,再重啟MySQL服務 在 cmd 中進入MySQL的bin目錄 C:\Users\Administrato

ubuntu 上Access denied for user 'root'@'localhost' (using password:YES) 的解決方案

在ubuntu系統通過apt-get 安裝好mysql 並且配置好密碼後, 使用這個命令“mysql -uroot -pmyadmin”後出現以下錯誤: “Access denied for user 'root'@'localhost' (using password:Y

php連線mysql報錯mysql_connect(): Access denied for user 'root'@'localhost' (using password: YES)

mysql_connect(): Access denied for user ‘root’@‘localhost’ (using password: YES) 1、連線密碼輸錯,檢查程式碼 2、wam

ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)問題的解決辦法

ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)該故障碼的意思是拒絕訪問資料庫。 一般出現該故障碼是由於資料庫的賬號或密碼被更改過所致。解決的辦法是更改資

關於java.sql.SQLException: Access denied for user 'root'@'localhost' (using password: YES)問題解決

今天使用mybatis框架進行資料庫訪問時,出現: org.apache.ibatis.exceptions.PersistenceException:  ### Error querying database.  Cause: java.sql.SQLException:

Access denied for user 'root'@'localhost' (using password:YES) Mysql5.7

解決方案: (1) 開啟MySQL目錄下的my.ini檔案,在檔案的最後新增一行“skip-grant-tables”,儲存並關閉檔案。(my.ini在C:\ProgramData\MySQL\MySQL Server 5.7\my.ini) (2)重啟MySQL服務。 (3)通過命令列進入MySQ

出現錯誤 連線MySQL資料庫,出現問題:Access denied for user 'root'@'localhost' (using password:YES)

連線MySQL資料庫,出現問題:Access denied for user 'root'@'localhost' (using password:YES)。         經查詢資料發現是ro

免安裝Mysql在Mac中的神坑之Access denied for user 'root'@'localhost' (using password: YES)

眼看馬上夜深人靜了,研究了一天的問題也塵埃落定了。 廢話不多說 直接來乾貨!大家都知道免安裝版本的Mysql, 在Mac中安裝完成(如何安裝詳見Mac OS X 下 TAR.GZ 方式安裝 MySQ