共計 1126 個字符,預計需要花費 3 分鐘才能閱讀完成。
這篇文章主要介紹了 linux 中 mysql 1045 錯誤如何解決的相關知識,內(nèi)容詳細易懂,操作簡單快捷,具有一定借鑒價值,相信大家閱讀完這篇 linux 中 mysql 1045 錯誤如何解決文章都會有所收獲,下面我們一起來看看吧。
解決方法:1、登錄數(shù)據(jù)庫之后,利用“select host,user from user;”語句查詢用戶和權限;2、利用“grant select,update,insert,delete on mas.* to 新建用戶 @localhost identified by 密碼”語句添加普通權限的用戶,重新登錄 mysql 數(shù)據(jù)庫即可。
本教程操作環(huán)境:linux7.3 系統(tǒng)、mysql8.0.22 版本、Dell G3 電腦。
linux 中 mysql 的 1045 錯誤解決的方法
開始使用 Linux 連接 mysql 數(shù)據(jù)庫的時候,出現(xiàn)了 1045 錯誤。當出現(xiàn)這個問題的時候,應該是用戶被數(shù)據(jù)庫拒絕訪問了,我們應該為你的數(shù)據(jù)庫開辟權限。
1、查詢數(shù)據(jù)庫用戶權限
登錄數(shù)據(jù)庫輸入 linux 指令
mysql -uroot -padmin
登錄你的數(shù)據(jù)庫輸入用戶名和密碼
使用數(shù)據(jù)庫,查詢權限
mysql use mysql;
mysql select host,user from user;
可以查詢用戶和權限
2、想要遠程 mysql 服務器,需要增加普通權限的用戶
mysql grant select,update,insert,delete on mas.* to root@localhost identified by admin
grant select,update,insert,delete on mas.* to 新建用戶 @localhost identified by 密碼
這句命令的意思是:新建用戶 root,并且只允許該用戶在本地(localhost)登錄,密碼是 admin,并且賦予它對 mas 庫中所有表 select,update,insert 的權限。我們在這有一個 mas 庫,所以用 mas.* 代表 mas 庫下的所有表。現(xiàn)在該 root 用戶,已經(jīng)可以登錄 mysql 了,但是也還是只能本地登錄。
若要想 root 用戶可以遠程登錄 mysql,則還需要以下命令:
mysql update user set host = % where user = root
我們也可以直接給用戶權限
grant all on *.* to 用戶名 @ % identified by 密碼
flush privileges; 刷新權限
關于“l(fā)inux 中 mysql 1045 錯誤如何解決”這篇文章的內(nèi)容就介紹到這里,感謝各位的閱讀!相信大家對“l(fā)inux 中 mysql 1045 錯誤如何解決”知識都有一定的了解,大家如果還想學習更多知識,歡迎關注丸趣 TV 行業(yè)資訊頻道。