开发者

error in connecting to mysql server remotely , but locally it works fine

I have mysql installed on my local windows pc(windows 7).Now i have wrriten a program that interacts with db and and gives me the results .The program works fine when i run it on same machine which has mysql locally.

Now i run the program remotely from a different machine it gives me some error as show below.I have correctly set rmeote machine name and port.And i am able to ping mysql server machine from the other mahachine

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

After googling i found :

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 s开发者_JAVA百科tarted 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.

Now if this is to be done where can i do it?Which property i should change to which value.Which file i should change and what should i change?


Add new account:

  • 'user1'@'exact_host' - host is specified

    CREATE USER 'user1'@'exact_host'

or

  • 'user1'@'%' - for any host.

    CREATE USER 'user1'@'%'

Grant privileges you need and connect with new account.


in the file /etc/mysql/my.cnf you don't want to have:

bind-address                            = 127.0.0.1

or

skip-networking

if they exist, add a # infront to disable them, and then reload/restart mysql after that the server should be open for remote connections you may want to add some restriction for whos alowed to connect in your firewall


You may check for "skip-networking" line in your MySQL's configuration file.

Here's another thing I found about this error: In Causes of Access-Denied Errors (MySQL 5.5 Reference Manual) they say (if I got it right) that if you try to connect from an address that isn't covered by any of the existing MySQL accounts, the error message would be the one you're getting, instead of the usual "Access denied for user ...". I'd suggest checking the host part in your MySQL accounts (for example, if the remote machine is @ 192.168.1.15, are there accounts like '...'@'192.168.1.15' or '...'@'%' ?).


I had this problem and i could resolve this with the mysql server instance configuration wizard

C:\Program Files\MySQL\MySQL Server 5.1\bin\MySQLInstanceConfig.exe.

Open it and click the option Enable root access from remote machines.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜