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密碼設置(不知道是不是安裝過程有被忽略的地方?)。
對此就各種尋找答案,大致有下面一些情況:
有說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服務器上報錯“模板不存在”如何解決
- linux mysql 報錯:MYSQL:The server quit without updating PID file
- Linux常見英文報錯中文翻譯(菜鳥必知)
相關文章
MYSQL必知必會讀書筆記第四章之檢索數(shù)據(jù)
MySQL是一種開放源代碼的關系型數(shù)據(jù)庫管理系統(tǒng)(RDBMS)。接下來通過本文給大家介紹MYSQL必知必會讀書筆記第四章之檢索數(shù)據(jù),感興趣的朋友一起學習吧2016-05-05mysql數(shù)據(jù)庫decimal類型與decimal長度用法詳解
在MySQL中decimal是一種用于存儲精確數(shù)字的數(shù)據(jù)類型,下面這篇文章主要給大家介紹了關于mysql數(shù)據(jù)庫decimal類型與decimal長度用法的相關資料,文中通過代碼介紹的非常詳細,需要的朋友可以參考下2024-01-01多次執(zhí)行mysql_fetch_array()的指針歸位問題探討
多次執(zhí)行mysql_fetch_array(),在第二次執(zhí)行的時候,如果不加處理,就不會輸出任何內容,這種情況下只需要對循環(huán)指針進行復位即可,感興趣的朋友可以了解下啊,或許對你有所幫助2013-01-01CentOS 6.2 安裝 MySQL 5.7.28的教程(mysql 筆記)
本文通過圖文并茂的形式給大家介紹了CentOS 6.2 安裝 MySQL 5.7.28的教程,非常不錯,具有一定的參考借鑒價值,需要的朋友參考下吧2019-11-11MySQL下使用Inplace和Online方式創(chuàng)建索引的教程
這篇文章主要介紹了MySQL下使用Inplace和Online方式創(chuàng)建索引的教程,針對InnoDB為存儲引擎的情況,需要的朋友可以參考下2015-11-11