The online racing simulator
Problem connecting to remote MySql
Hello. I'm having a problem when connecting to a database in a remote server.

The error I get: "Can't connect to MySQL server on '...' (10061)"

The code:

if (mysql_real_connect(sock, host, user, password, database, 0 , 0, 0))
cout << "ok" << endl << endl;
else
cout << mysql_error(sock) << endl;

When I ping the host it responds.
Works when I try with a local database.
User, password and database name are correct.

Any ideas?
Might be a stupid question, but are you trying to connect to the remote database with the 'root' username?
Nope, I have a user and pass just for it.
Search "mysql erorr 10061" gives hints to what may happen: in MS Windows it is when a port is closed or a firewall. In case of web servers, I guess it means the port is closed.
With my sysadmins hat on I wouldn't recommend opening your MySQL server to the world. If you do need remote access lock it down to IP(s) at the firewall, use IPsec to secure the traffic, or use some other form of tunneling.
Since this is a remote server you might try increasing the 'max_allowed_packets' setting in your mysql config file. Not sure how much data you are sending to the server at one time, but I have an experience this week on our webserver at work that caused me to have to increase the amount allowed. I would try different port/firewall settings first though. It has been reported that the 'max_allowed_packets' increase can cause a performance hit on the database server. However, I cannot confirm or deny that statement.

Good Luck! and back up those config files first!

Edit* You know. Unless you are send a lot of data ( > 1m at a time) then max_allowed_packets is not the problem. I thought about the settings for allowed hosts for each user account. Default is local. So a SSH tunnel would bounce off the loopback and hit the database from the localhost, since most mysql users are setup this way. Or you could change it to allow the host you are connecting from. I may be giving you information you already know, but i thought i would throw this out there.
Just to let you know he did figure it out earlier tonight... I don't know what actually happened but we did get it working
Yes, thank you everyone... it's working now
Quote from de Souza :Yes, thank you everyone... it's working now

Good to hear! What did you have to do?
Well we had to move to another server anyway, and with the new one we didn't have any problems (just had to grant privileges to the user).
But seems like it was because of a firewall, as detail said.


FGED GREDG RDFGDR GSFDG