問題描述
在 Windows XP 上運行的 MySQL 5.1.31.
MySQL 5.1.31 running on Windows XP.
從 本地 MySQL 服務器 (192.168.233.142) 我可以以 root 身份連接,如下所示:
From the local MySQL server (192.168.233.142) I can connect as root as follows:
>mysql --host=192.168.233.142 --user=root --password=redacted
從遠程機器(192.168.233.163),我可以看到mysql端口是開放的:
From a remote machine (192.168.233.163), I can see that the mysql port is open:
# telnet 192.168.233.142 3306
Trying 192.168.233.142...
Connected to 192.168.233.142 (192.168.233.142).
但是當我嘗試從 遠程 機器連接到 mysql 時,我收到:
But when trying to connect to mysql from the remote machine, I receive:
# mysql --host=192.168.233.142 --user=root --password=redacted
ERROR 1045 (28000): Access denied for user 'root'@'192.168.233.163' (using password: YES)
我在 mysql.user 中只有 2 個條目:
I have only 2 entries in mysql.user:
Host User Password
--------------------------------------
localhost root *blahblahblah
% root [same as above]
我還需要做什么才能啟用遠程訪問?
What more do I need to do to enable remote access?
編輯
正如下面 Paulo 所建議的,我嘗試將 % 的 mysql.user 條目替換為特定于 IP 的條目,因此我的用戶表現(xiàn)在如下所示:
As suggested by Paulo below, I tried replacing the mysql.user entry for % with an IP specific entry, so my user table now looks like this:
Host User Password
------------------------------------------
localhost root *blahblahblah
192.168.233.163 root [same as above]
然后我重新啟動了機器,但問題仍然存在.
I then restarted the machine, but the problem persists.
推薦答案
Paulo 的幫助引導我找到解決方案.它是以下內(nèi)容的組合:
Paulo's help lead me to the solution. It was a combination of the following:
- 密碼包含美元符號
- 我試圖從 Linux shell 進行連接
bash shell 將美元符號視為 擴展 到環(huán)境變量,所以我們需要用反斜杠轉(zhuǎn)義它.順便說一下,如果美元符號是密碼的最后一個字符,我們不必這樣做.
The bash shell treats the dollar sign as a special character for expansion to an environment variable, so we need to escape it with a backslash. Incidentally, we don't have to do this in the case where the dollar sign is the final character of the password.
舉個例子,如果你的密碼是pas$word",從Linux bash我們必須按如下方式連接:
As an example, if your password is "pas$word", from Linux bash we must connect as follows:
# mysql --host=192.168.233.142 --user=root --password=pas\$word
這篇關(guān)于啟用遠程 MySQL 連接:ERROR 1045 (28000): Access denied for user的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!