2011-08-11 34 views
0

我有我的本地Windows PC(Windows 7)上安裝的MySQL。現在我有一個程序,與數據庫互動,並給我結果。很好,當我在本地有mysql的同一臺機器上運行它時。
現在我從不同的機器上遠程運行程序它給了我一些錯誤的顯示below.I已正確設置rmeote機器名和port.And我能夠平安MySQL服務器的機器與其他mahachine遠程連接到mysql服務器的錯誤,但本地工作正常

java.sql.SQLException: null, message from server: "Host 'remote-pc-name' is not allowed to connect to this MySQL server" 

谷歌搜索後,我發現:
Make sure that the server has not been configured to ignore network connections or (if you are attempting to connect remotely) that it has not been configured to listen only locally on its network interfaces. If the server was started with --skip-networking, it will not accept TCP/IP connections at all. If the server was started with --bind-address=127.0.0.1, it will listen for TCP/IP connections only locally on the loopback interface and will not accept remote connections

現在,如果要做到這一點,我可以在哪裏做到這一點?哪個屬性我應該改變爲哪個值。哪個文件我應該改變,我應該改變什麼?

+0

你對遠程機器有管理員權限嗎? –

+0

檢查'mysql數據庫,表用戶,數據庫' – ajreal

+0

是的,我做的一切都很好 – akshay

回答

4

添加新帳號:

  • 'user1的' @ 'exact_host' - 主機指定

    CREATE USER '用戶1' @ 'exact_host'

  • 'user1'@'%' - 適用於任何主機。

    創建所需的用戶USER1'@ '%'

授予權限,並與新的帳戶連接。

0
文件/etc/mysql/my.cnf 在

你不希望有:

bind-address       = 127.0.0.1 

skip-networking 
如果它們存在

,添加#盈禁用它們, ,然後重新加載/重新啓動mysql 之後,服務器應該打開遠程連接 您可能想要添加一些限制誰可以在你的防火牆連接誰

+0

:謝謝你的回覆,但我在windows上使用mysql,並且找不到my.cnf文件。我查看了my.ini,但是找不到那些屬性,請問你能幫忙嗎? – akshay

+0

谷歌說它的%SYSTEMROOT%\ my.ini –

+0

我已經檢查過它,但我無法找到這樣的propery在該文件 – akshay

0

您可以在MySQL的配置文件中檢查「skip-networking」行。我發現了這個錯誤的另一件事:在Causes of Access-Denied Errors(MySQL 5.5參考手冊)中,他們說(如果我正確的話),如果你嘗試從一個沒有被任何現有MySQL覆蓋的地址進行連接帳戶,錯誤信息將是你得到的,而不是通常的「訪問拒絕用戶...」。我建議檢查您的MySQL帳戶中的主機部分(例如,如果遠程機器是@ 192.168.1.15,是否有帳戶像'...'@'192.168.1.15'或'...'@'% '?)。

0

我有這個問題,我可以與MySQL服務器實例配置嚮導

C:\Program Files\MySQL\MySQL Server 5.1\bin\MySQLInstanceConfig.exe解決這個問題。

打開它並單擊選項啓用遠程機器的root訪問權限。

相關問題