2013-07-01 60 views
0

我有一個MySQL數據庫在聯網的計算機上運行。過去我沒有遇到任何麻煩。然而,突然間(重啓和週末),我得到MySQL連接IP從指定的IP地址變化

ERROR 1045 (28000): Access denied for user 'root'@'x.x.x.y'. 

這是因爲我想通過連接非常奇怪:

mysql -h x.x.x.x -u root 

出於某種原因,我的IP地址(終幾個數字後的最後'。')我試圖連接到我輸入的變化。

我正在運行Ubuntu 12.10。

編輯:遠程連接已啓動並且可以ping通。 Mysql在計算機上也能正常工作。

回答

0

-h標誌後面輸入的IP地址/主機名稱是您要連接到的MySQL服務器的IP地址/主機名稱。錯誤消息中的IP地址/主機名是您連接的計算機的IP地址/主機名。可能您對動態分配的IP地址進行了更改,並且您的用戶帳戶未設置爲允許從該帳戶進行訪問。

+1

這正是問題所在。由於我最初是通過子網上的路由器連接的,所以它比通常情況下更加混亂,但是然後將路由器換出來,仍然可以正常連接。但是,顯然我的地址改變了,所以我不認爲這個錯誤是指我自己的IP。謝謝。 – user2502003

3
You will need to reset the password. 

First start the mysql server instance or daemon with the --skip-grant-tables option. (security setting) 

Then Execute these statements. 
# mysql -u root mysql 
mysql> UPDATE user SET Password=PASSWORD('your_new_password') where USER='root'; 
mysql> FLUSH PRIVILEGES; 

Finally, restart the instance/daemon without the --skip-grant-tables option. 

You should be able to connect with your new password. 

# mysql -u root -p 
Enter password: your_new_password`enter code here` 

Hope this helps.