前提嘮叨:
剛學了mysql準備在自己的虛擬機器上回家玩玩,結果mysql就立馬給我一個下馬威,拒絕串連root使用者,首先呢,我耐心的在網上尋找解決之道,確實發現很多,但歸納起來也就三四種,再折騰了2個多小時挨個試完之後發現,沒有一個可以解決我這個問題。過了兩天碰到老師我向他諮詢了一下,結果回來立馬就解決了!牛!
再囉嗦兩句,首先你得是跟我相似或者一樣的應用環境,這個很重要,不同的環境下結果可能呈現萬般不同;然後呢,我這是只是快速的解決進入mysql的問題,至於進去之後你要不要再添設密碼以加強安全什麼的不在今天所說之列,閑話稍許,下面是正題。
環境:RedHat企業版5.9
使用者:root
[root@localhost ~]# mysql
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
1、這時我想那我添設個初始密碼唄!話說初始化之後應該是可以匿名進入的才對啊!
[root@localhost ~]# mysqladmin -hlocalhost -uroot password"123"
mysqladmin: connect to server at 'localhost' failed
error: 'Access denied for user 'root'@'localhost' (using password: NO)'
2、設定失敗,既然這樣我只能試一試老師說到的mysql的設定檔
[root@localhost ~]# vim /etc/my.cnf
[mysqld]
skip-grant-table //這句表達的意思呢是“跳過授權表,即無密碼直接進入啦”
3、重啟服務
[root@localhost ~]# service mysqld restart
停止 mysqld: [確定]
啟動 mysqld: [確定]
4、再次進入
[root@localhost ~]# mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.0.95 Source distribution
Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>
嘿嘿,終於看到這個向右的小箭頭了!
雖然簡單,但若能幫到某人,我會很開心的。
更多相關閱讀:
MySQL ERROR 1045 (28000): Access denied for user 'root'@'localhost'
解決MySQL安裝時1045錯誤的方法
Linux下MySQL遠端連線提示ERROR 1045 (28000)
MySQL出現1045錯誤服務找不到路徑的解決