2012-04-10 231 views
2

即使我重新用下面的命令root密碼無法登錄到MySQL:(上市提供額外的信息等命令)無法啓動mysql

# sudo dpkg-reconfigure mysql-server-5.1 

    # mysql -u root -p 
    Enter password: 
    ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES) 

    # telnet 127.0.0.1 3306 
     Trying 127.0.0.1... 
     telnet: Unable to connect to remote host: Connection refused 
    # ps -Aw |grep mysql 
     26522 ?  00:00:00 mysqld 

    # /etc/init.d/mysql start 
    Rather than invoking init scripts through /etc/init.d, use the service(8) 
    utility, e.g. service mysql start 

    Since the script you are attempting to invoke has been converted to an 
    Upstart job, you may also use the start(8) utility, e.g. start mysql 

更新:

 # sudo mysqladmin -u root password 123 
    mysqladmin: connect to server at 'localhost' failed 

它似乎MySQL沒有正常運行

更新: 我在Ubuntu下使用MySQL 5.1。 直到我在my.cnf中進行一些更改以啓用遠程訪問才行。我撤銷了我的更改,但問題沒有解決! (也許我忘了取消某些東西!)

更新:

 # service mysql status 
    mysql start/running, process 26650 
    # /etc/init.d/mysql status 
    Rather than invoking init scripts through /etc/init.d, use the service(8) 
    utility, e.g. service mysql status 

    Since the script you are attempting to invoke has been converted to an 
    Upstart job, you may also use the status(8) utility, e.g. status mysql 
    mysql start/running, process 26650 
+1

使用mysqladmin命令創建root密碼 – kappa 2012-04-10 13:32:33

+0

對不起,我遲到的反應 - 如果你還沒有固定的問題是,試圖發佈您的my.cnf文件(當然沒有敏感信息)。如果您在遠程訪問時玩遊戲,可以想象,本地訪問被意外禁用。還可以考慮將日誌記錄添加到my.cnf文件中以更好地瞭解發生了什麼(通過'log-error =/var/log/mysqld.log')。 – Matthematics 2012-04-17 17:02:40

+0

@Lübnah謝謝,我決定重新安裝MySQL。但是,本地訪問如何被禁用? – PHPst 2012-04-18 03:10:31

回答

2

設置root的密碼:

mysqladmin -u root password NEWPASSWORD 

進行恢復: http://www.cyberciti.biz/tips/recover-mysql-root-password.html

+0

sudo mysqladmin -u root密碼123 mysqladmin:在'localhost'連接服務器失敗 – PHPst 2012-04-10 13:37:29

+0

是你的mysql服務器啓動並運行了嗎?嘗試/etc/init.d/mysqld重新啓動,看看會發生什麼 – kappa 2012-04-10 16:37:27

+0

在您的第一個錯誤服務器響應,而在下一個塊的情況是不同的。還是這樣? – kappa 2012-04-11 07:43:22

2

我最好的猜測是,如果您已重新配置/重新安裝MySQL,則需要無需密碼登錄,例如:

mysql -u root

甚至

mysql


編輯:要查看是否正在運行的服務,您可以嘗試:

service mysqld status

,如果它沒有運行,請嘗試:

service mysqld start然後再次檢查狀態。

+0

無效 – PHPst 2012-04-10 13:38:18

+0

嘗試上面編輯的第二部分,可能是mysql服務沒有運行。我最近遇到過這個問題。 – Jonathan 2012-04-10 13:52:58

+0

/sbin /服務mysqld狀態 -bash:/ sbin/service:沒有這樣的文件或目錄 – PHPst 2012-04-10 13:59:44

1

這似乎是MySQL絕對沒有運行。您可以用/etc/init.d/mysqld statusservice mysqld status(不要直接鏈接到服務命令)來驗證。

我的spidey感告訴我你的O/S或MySQL安裝不正確。這將有助於瞭解更多關於您正在運行的(linux?)環境以及它如何配置(或者誰配置它,在PaaS中)的信息。

0

開始作爲一種服務

sudo的服務mysql的重啓

驗證&檢查服務和端口

須藤netstat的抽頭| grep的MySQL的

Screen shot of check the mysql service running

0

你應該改變的訪問權限。它應該是0644

sudo chmod 644 /etc/mysql/my.cnf 

然後

sudo dpkg-reconfigure mysql-server-5.5