linux下 root 登錄 MySQL 報(bào)錯(cuò)的問(wèn)題
最近在centOS 7上,通過(guò)yum安裝了mysql,安裝成功后,使用root登錄,出現(xiàn)了如下報(bào)錯(cuò):
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
然而實(shí)際上并沒(méi)有進(jìn)行過(guò)root密碼設(shè)置(不知道是不是安裝過(guò)程有被忽略的地方?)。
對(duì)此就各種尋找答案,大致有下面一些情況:
有說(shuō)root的隨機(jī)密碼位于/root/.mysql_secret中,但是我根本沒(méi)有/root/.mysql_secret文件。有文章表示
> ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using > password: NO) :表示沒(méi)有生成root的臨時(shí)密碼 > > ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using > password: YES) :表示生成了root的臨時(shí)密碼。
有些資料說(shuō)root的默認(rèn)密碼為空,經(jīng)過(guò)確認(rèn)那是以前的老版本,Mysql 5.6及以后版本出處于安全考慮,root密碼已經(jīng)不為空了。
最終找到對(duì)我來(lái)說(shuō)有用的解決方案。
產(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ā)布出來(lái),供大家參考。
- Linux連接mysql報(bào)錯(cuò):Access denied for user ‘root’@‘localhost’(using password: YES)的解決方法
- Linux 初始化MySQL 數(shù)據(jù)庫(kù)報(bào)錯(cuò)解決辦法
- linux 環(huán)境 mysql寫(xiě)入中文報(bào)錯(cuò)
- linux mount報(bào)錯(cuò):you must specify the filesystem type的解決方法
- thinkphp項(xiàng)目部署到Linux服務(wù)器上報(bào)錯(cuò)“模板不存在”如何解決
- linux mysql 報(bào)錯(cuò):MYSQL:The server quit without updating PID file
- Linux常見(jiàn)英文報(bào)錯(cuò)中文翻譯(菜鳥(niǎo)必知)
相關(guān)文章
MYSQL必知必會(huì)讀書(shū)筆記第四章之檢索數(shù)據(jù)
MySQL是一種開(kāi)放源代碼的關(guān)系型數(shù)據(jù)庫(kù)管理系統(tǒng)(RDBMS)。接下來(lái)通過(guò)本文給大家介紹MYSQL必知必會(huì)讀書(shū)筆記第四章之檢索數(shù)據(jù),感興趣的朋友一起學(xué)習(xí)吧2016-05-05這種sql寫(xiě)法真的會(huì)導(dǎo)致索引失效嗎
這篇文章主要給大家介紹了關(guān)于網(wǎng)上流傳的某種sql寫(xiě)法會(huì)導(dǎo)致索引失效的相關(guān)資料,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家學(xué)習(xí)或者使用sql具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2019-07-07mysql數(shù)據(jù)庫(kù)decimal類(lèi)型與decimal長(zhǎng)度用法詳解
在MySQL中decimal是一種用于存儲(chǔ)精確數(shù)字的數(shù)據(jù)類(lèi)型,下面這篇文章主要給大家介紹了關(guān)于mysql數(shù)據(jù)庫(kù)decimal類(lèi)型與decimal長(zhǎng)度用法的相關(guān)資料,文中通過(guò)代碼介紹的非常詳細(xì),需要的朋友可以參考下2024-01-01多次執(zhí)行mysql_fetch_array()的指針歸位問(wèn)題探討
多次執(zhí)行mysql_fetch_array(),在第二次執(zhí)行的時(shí)候,如果不加處理,就不會(huì)輸出任何內(nèi)容,這種情況下只需要對(duì)循環(huán)指針進(jìn)行復(fù)位即可,感興趣的朋友可以了解下啊,或許對(duì)你有所幫助2013-01-01CentOS 6.2 安裝 MySQL 5.7.28的教程(mysql 筆記)
本文通過(guò)圖文并茂的形式給大家介紹了CentOS 6.2 安裝 MySQL 5.7.28的教程,非常不錯(cuò),具有一定的參考借鑒價(jià)值,需要的朋友參考下吧2019-11-11MySQL下使用Inplace和Online方式創(chuàng)建索引的教程
這篇文章主要介紹了MySQL下使用Inplace和Online方式創(chuàng)建索引的教程,針對(duì)InnoDB為存儲(chǔ)引擎的情況,需要的朋友可以參考下2015-11-11使用limit,offset分頁(yè)場(chǎng)景時(shí)為什么會(huì)慢
這篇文章主要介紹了使用limit,offset分頁(yè)場(chǎng)景時(shí)為什么會(huì)慢,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2019-11-11