1

I can not connect to MySQL server from a remote computer. When I try to connect it gives me the error

Host '' is not allowed to connect to this MySQL server

I've edited the MySQL server my.ini file by changing the bind line from #bind = "127.0.0.1" to bind = *. I've turned off the firewall of the client machine trying to access the server. I also gave full privilege to the user of MySQL database through which I am trying to connect to the server by using the MySQL grant command, but nothing seems to be working.

Please help me.

Thanks

1
  • 1
    Show exactly how the MySQL user is setup especially the host part of the 'user'@'host'
    – RiggsFolly
    Commented Feb 11, 2015 at 21:56

3 Answers 3

2

A MySQL user has a "from host" field. This is probably set to some IP and those mismatch, giving you that error. This field allows for extra security and can be set to any IP/hostname. If this field is set for the user then you can only login to the MySQL server with that user from the IP/hostname specified. If you want to test your connection you can just use a wildcard for the "from host" field % so that any IP can connect using that user, I wouldn't recommend this in a product environment though.

4
  • To expand on this answer, the way to see where a user can connect from, do a show grants for <user> command. You will see the permission being granted to '<user>'@'<host>'. You want to make sure that the <host> is '%' and not 'localhost'. Commented Feb 11, 2015 at 18:29
  • thanks alot it worked. u said using the wildcard % for the host field, for a user is not recommended in a production environment, please why, what are the implication.
    – Eunice
    Commented Feb 11, 2015 at 19:58
  • is there any way to specify a range of ip's that should connect to the database through that user?
    – Eunice
    Commented Feb 11, 2015 at 19:59
  • Yes, just re-add the user you want with the same password multiple times for different hosts/IP's.
    – Jamey D
    Commented Feb 11, 2015 at 20:01
1

First check if you can connect to port 3306. You can use telnet for this, from your client system execute telnet <server ip> 3306 You should get connected or asked for a password.

Also you can see if the port is open for outside connection by executing netstat -an to get the list of open ports and the listening ip.

If that works then try to use a mysql client to connect using mysql -h <hosst> -u <user> -p <database>

0

Sounds like you may need to grant privileges to connect to the database, to the user/host that is trying to connect. See http://dev.mysql.com/doc/refman/5.1/en/grant.html.

1
  • i've done that already and its still not working
    – Eunice
    Commented Feb 11, 2015 at 18:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.