PDA

View Full Version : "QMYSQL: unable to connect"



anteevy
14th October 2010, 18:45
Hi, I'm having problems connecting to my MySQL server. It works fine with the localhost (XAMPP), but I get an error when I try to connect to the one of my one.com webserver. I'm sure my access data is right (as I'm using it with several CMS), but QSqlDatabase::open() always fails with "Can't connect to MySQL server on 'anteevy.de' (10060) QMYSQL: Unable to connect".

Any ideas?

Talei
14th October 2010, 19:14
If You are sure that there is no error in the code, then that's probably because host company that Your web page is hosted on don't allow connection to the DB from the external IP (due to security reasons).

gboelter
15th October 2010, 07:53
Try 'mysql -h anteevy.de -u username -p password' and see, if you can get a connection. Don't forget to replace username and password.

anteevy
15th October 2010, 23:08
Okay, I guess it's not Qt related. I get the same errors with the command line. When using "anteevy.de" as the mysql host, I get "can't connect to mysql server" and with "anteevy.de.mysql" (that's what I'm using as host name in several CMS) I directly get a "unknown mysql server host". Is there something I would have to append to that? Something like mysql:// (no idea?)?

Lykurg
15th October 2010, 23:39
No it is like it was said: Provider only allow access to their databases from scripts which run on their servers. That's the normal way. Or do you have a remote server, then you possible are allowed to access from everywhere. But simply have a look at the privileges your mysql user has. There is defined from which host your user is allowed to connect. Or ask your provider.

Talei
16th October 2010, 10:53
@anteevy
When Host company block You external DB access there is one thing You can do to get it to work, that is create PHP script that will take as arg SQL query and response request result (or JSON/XML whatever You really want).

Lykurg
16th October 2010, 11:14
@anteevy
When Host company block You external DB access there is one thing You can do to get it to work, that is create PHP script that will take as arg SQL query and response request result (or JSON/XML whatever You really want).And then you only have to wait till the provider closes your account since that is against the contract rules. (at least against the common rules for web hosts.)

Talei
16th October 2010, 13:05
Well that depends on the contract that You have with host companies, so when You do something like that You need to know what's "Do" and "Do Not".
And basically connection is made to DB from localhost, so I doubt that they will monitor scripts, and how would they know if access is not done for internal WEB purpose?
I mean how would they know that You use external prog. and not the Web Browser to hit the page? (It's simply GET or POST HTTP request)