0

In C#, windows forms, I'm trying to connect to a web server (for testing, 000webhost.com) and whatever I do it keeps saying "Host 'xxx.xxx.xxx.xxx' is not allowed to connect to this MySQL server" (where the X's are my WAN IP address).

If I do this on localhost, then it works perfectly fine, but whenever I try to connect to a database on any web server that exception gets thrown. Why does it do that and how can I fix it?

John Powell
  • 12,253
  • 6
  • 59
  • 67
BlazE
  • 81
  • 1
  • 16
  • mysql username is host based in the syntax `user@hostname_or_ip`. This error means your user don't have permission to connect from the host you are trying to connect. http://dev.mysql.com/doc/refman/4.1/en/adding-users.html – bansi Jul 29 '14 at 12:47
  • are you trying to connect as root, or another user? – ajg Jul 29 '14 at 12:48

2 Answers2

1

You must configure the MySQL server to allow connections from other computers than local host only.

Bernhard Hiller
  • 2,163
  • 2
  • 18
  • 33
1

probably there's a mysql configuration which prevents you from connecting outside localhost. you have to bind all addresses permitted to connect to the server and comment out or delete line relative to skip-networking. open your my.cnf configuration file (depends on machine you are on) but it should be on

/etc/mysql/my.cnf

delete bind-address line or set it to this value:

bind-address 0.0.0.0

comment out or delete it:

#skip-networking

reboot mysql server:

service mysql(d) restart

now you should be able to connect to it from any host.

blurstream
  • 429
  • 3
  • 13
  • Where can I find /etc/mysql/my.cnf file? – BlazE Jul 29 '14 at 13:27
  • what o.s. are you running? – blurstream Jul 29 '14 at 13:32
  • Windows 7 Ultimate, Service Pack 1 – BlazE Jul 29 '14 at 13:34
  • it should be here: C:\Users\All Users\MySQL\MySQL Server X.X\my.ini where X.X is mysql version – blurstream Jul 29 '14 at 13:37
  • Nope, directory "All Users" doesn't exist and i've done a full search on "my.ini" file and nothing has been found. The location is actually here: C:\Program Files\MySQL\MySQL Server 5.6\ and there's a file called "my-default.ini". Maybe that's the one? – BlazE Jul 29 '14 at 13:39
  • if it is the only configuration file with these directives, yes, it should be the one – blurstream Jul 29 '14 at 13:49
  • no, it doesn't seem the configuration file: is there a bin folder in that path? maybe inside there is my.cnf configuration file – blurstream Jul 29 '14 at 14:22
  • No, in the bin folder are just a bunch of .exe and .pl files. – BlazE Jul 29 '14 at 14:25
  • right, don't you see any my.ini in basic installation folder? – blurstream Jul 29 '14 at 14:33
  • Ah hell, I finally found it thanks to [this](http://stackoverflow.com/questions/1712646/i-can-not-find-my-cnf-on-my-windows-computer) . Now I tried to do what you told me but bind-address line isn't even there and skip-networking has already been commented. Now what? :/ – BlazE Jul 29 '14 at 14:48