您好,登錄后才能下訂單哦!
本篇內容介紹了“怎么解決MySQL中的ERROR 1045 (28000)錯誤問題”的有關知識,在實際案例的操作過程中,不少人都會遇到這樣的困境,接下來就讓小編帶領大家學習一下如何處理這些情況吧!希望大家仔細閱讀,能夠學有所成!
一、錯誤描述:
錯誤如標題:ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)。我用root@localhost授權登陸,然后給其中
一個用戶授權,然后報如上錯誤:
[mysql@centos6-clone ~]$ mysql -u root -p
Enter password:
Your MySQL connection id is 2
Server version: 5.6.25-log MySQL Community Server (GPL)
mysql> grant all on *.* to 'fi'@'127.0.0.1' identified by "fi";
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
mysql> exit
Bye
按理來說,root@localhost是最高權限。居然不能給其他人授權。1045錯誤是授權拒絕。怎么辦?
二、錯誤分析
查看下root權限:
mysql> show grants;
+----------------------------------------------------------------------------------------------------------------------+
| Grants for root@localhost |
+----------------------------------------------------------------------------------------------------------------------+
| GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' IDENTIFIED BY PASSWORD '*E74858DB86EBA20BC33D0AECAE8A8108C56B17FA' |
| GRANT PROXY ON ''@'' TO 'root'@'localhost' WITH GRANT OPTION |
+----------------------------------------------------------------------------------------------------------------------+
2 rows in set (0.00 sec)
我們看root@localhost 有權限:ALL PRIVILEGES,但是沒有WITH GRANT OPTION 語句,就是別人授權的權限。所以,不能授權的原因是:
沒有這個WITH GRANT OPTION 語句。
三、錯誤解決
知道原因了,解決問題就很簡單了。用另外一個方式登錄root@127.0.0.1,然后給root@localhost授權,這樣root@localhost 就可以給其他用戶
授權了。
[mysql@centos6-clone ~]$ mysql -uroot -p -h227.0.0.1
Enter password:
mysql> SHOW GRANTS
-> ;
+----------------------------------------------------------------------------------------------------------------------------------------+
| Grants for root@127.0.0.1 |
+----------------------------------------------------------------------------------------------------------------------------------------+
| GRANT ALL PRIVILEGES ON *.* TO 'root'@'127.0.0.1' IDENTIFIED BY PASSWORD '*E74858DB86EBA20BC33D0AECAE8A8108C56B17FA' WITH GRANT OPTION |
+----------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)
mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' IDENTIFIED BY PASSWORD '*E74858DB86EBA20BC33D0AECAE8A8108C56B17FA' WITH GRANT OPTION;
Query OK, 0 rows affected (0.00 sec)
mysql> exit
[mysql@centos6-clone ~]$ mysql -uroot -p
Enter password:
mysql> grant all on *.* to 'fo'@'%' identified by "fo";
Query OK, 0 rows affected (0.00 sec)
“怎么解決MySQL中的ERROR 1045 (28000)錯誤問題”的內容就介紹到這里了,感謝大家的閱讀。如果想了解更多行業相關的知識可以關注億速云網站,小編將為大家輸出更多高質量的實用文章!
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。