linux下 root 登錄 MySQL 報錯的問題
最近在centOS 7上,通過yum安裝了mysql,安裝成功后,使用root登錄,出現(xiàn)了如下報錯:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
mysql版本為:Ver 14.14 Distrib 5.7.10, for Linux(X86_64) using EditLine wrapper
然而實際上并沒有進行過root密碼設(shè)置(不知道是不是安裝過程有被忽略的地方?)。
對此就各種尋找答案,大致有下面一些情況:
有說root的隨機密碼位于/root/.mysql_secret中,但是我根本沒有/root/.mysql_secret文件。有文章表示
> ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using > password: NO) :表示沒有生成root的臨時密碼 > > ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using > password: YES) :表示生成了root的臨時密碼。
有些資料說root的默認密碼為空,經(jīng)過確認那是以前的老版本,Mysql 5.6及以后版本出處于安全考慮,root密碼已經(jīng)不為空了。
最終找到對我來說有用的解決方案。
產(chǎn)生原因:
Now that the password MySQL had generated is expired, the problem is reduced to getting this password to work again (1) or generate a new one (2). This can be accomplished by running MySQL with the skip-grant-tables option which would make it ignore the access rights:
解決方法:
Stop your MySQL server.
Add skip-grant-tables at the end of the [mysqld] section of my.cnf file and save it.
Start MySQL server.
In terminal, typemysql -u root -pto get into MySQL command prompt.
In the command prompt, typeUSE mysql;to get into the mysql database where it keeps database users.
Type
UPDATE user SET password_expired = 'N' WHERE User = 'root';
to let MySQL know the password is not expired (1) or
UPDATE user SET authentication_string = PASSWORD('YourNewPassword'), password_expired = 'N' WHERE User = 'root';
附上鏈接:Unable to access MySQL after it automatically generated a temporary password
發(fā)布出來,供大家參考。
- Linux連接mysql報錯:Access denied for user ‘root’@‘localhost’(using password: YES)的解決方法
- Linux 初始化MySQL 數(shù)據(jù)庫報錯解決辦法
- linux 環(huán)境 mysql寫入中文報錯
- linux mount報錯:you must specify the filesystem type的解決方法
- thinkphp項目部署到Linux服務(wù)器上報錯“模板不存在”如何解決
- linux mysql 報錯:MYSQL:The server quit without updating PID file
- Linux常見英文報錯中文翻譯(菜鳥必知)
相關(guān)文章
MySQL存儲過程之流程控制while,repeat,loop循環(huán)
這篇文章主要介紹了MySQL存儲過程之流程控制while,repeat,loop循環(huán),循環(huán)中的代碼會運行特定的次數(shù),或者是運行到特定條件成立時結(jié)束循環(huán)2022-07-07
mysql5.5 master-slave(Replication)配置方法
mysql5.5 master-slave(Replication)配置方法,需要的朋友可以參考下。2011-08-08
MySQL索引類型Normal、Unique和Full Text的講解
今天小編就為大家分享一篇關(guān)于MySQL索引類型Normal、Unique和Full Text的講解,小編覺得內(nèi)容挺不錯的,現(xiàn)在分享給大家,具有很好的參考價值,需要的朋友一起跟隨小編來看看吧2019-03-03
淺談MySql整型索引和字符串索引失效或隱式轉(zhuǎn)換問題
本文主要介紹了MySql整型索引和字符串索引失效或隱式轉(zhuǎn)換問題,文中通過示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下2021-11-11
ubuntu 16.04下mysql5.7.17開放遠程3306端口
這篇文章主要介紹了ubuntu 16.04下mysql5.7.17開放遠程3306端口的相關(guān)資料,具有一定的參考價值,感興趣的小伙伴們可以參考一下2017-01-01
MYSQL必知必會讀書筆記第七章之數(shù)據(jù)過濾
這篇文章主要介紹了MYSQL必知必會讀書筆記第七章之數(shù)據(jù)過濾的相關(guān)資料,需要的朋友可以參考下2016-05-05
mysql 5.7.16 安裝配置方法圖文教程(ubuntu 16.04)
這篇文章主要為大家分享了ubuntu 16.04下mysql 5.7.16 安裝配置方法圖文教程,具有一定的參考價值,感興趣的小伙伴們可以參考一下2017-01-01
mysql使用mysqld_multi部署單機多實例的方法教程
這篇文章主要給大家介紹了關(guān)于mysql使用mysqld_multi部署單機多實例的相關(guān)資料,文中通過示例代碼將實現(xiàn)的步驟一步步介紹的非常詳細,對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧。2018-03-03

