8

I have developed an application in VB6, and am using an online MySQL database server for storing my application's data.

The first time I try to connect to my database server is successful, but after closing my application and starting it again I get:

Can't connect to MySQL server(10060)"

After some time (approximately 30 minutes), I can successfully connect to the database again.

  • I have given maximum values to all of MySQL system and global variables like connection_timeout, wait_timeout etc.
  • I have granted all permissions to my MySQL user.
  • The firewall on my computer is turned off.
  • All connections are properly closed when the application closes.

I have asked the technical people who provide the Online MySQL Database service and they gave me these three reasons:

  1. The local machine from where you are trying to connect is not whitelisted on the server.
  2. The maximum number of connections for the user has been exceeded.
  3. The MySQL server was down at the time (though they said that their server was not down).

How can I solve the first two reasons, or determine that they are the cause of the problem? Or could there be another problem not listed there?

2

you need to make sure there is:

1) user created that has remote access for example user@'x.x.x.x'

2) there is a connection from the two machine ( they can ping each other for example or access each another by another method) the port is opened between the two machine

3) in my.ini/my.cnf there is blocking connection parameter like:bind-address=a.a.a.a or skip-networking

4) the service is up and running when you try to connect from the other machine

0

Most probably this is a networking side issue and the database service provider needs to create a new rule in firewall (iptables). Still we just need to confirm few things from the provider. As the behavior is not steady (on occasion you can connect, and sometimes not). So its not a user privilege issue (GRANT ALL ON ...)

  1. Make sure they have included MySQL listening port in to unblock/exception list of firewall. Most commonly it is 3306
  2. Try increasing the max_connection parameter in my.cnf
  3. In my.cnf make sure 'skip-networking' is commented out, Also bind-address = 127.0.0.1
  4. What is the output if we use the following from command line telnet ip_mysql_server 3306
  • 1
    on windows telnet is most probably not available: use powershell PS C:\Windows\system32> New-Object System.Net.Sockets.TcpClient("ip_mysql_server", 3306) Client : System.Net.Sockets.Socket Available : 78 Connected : True <== this indicates that you can reach the server ExclusiveAddressUse : False ReceiveBufferSize : 65536 SendBufferSize : 64512 ReceiveTimeout : 0 SendTimeout : 0 LingerState : System.Net.Sockets.LingerOption NoDelay : False – user906489 Jun 13 '18 at 11:52
0

Provide the output of the telnet (ip): port

I had the same issue last time and the iptables is the culprit at that time.

When the server got rebooted the iptables rule turns to default and it didn't apply the filter for certain ports.

Check the iptables

0

First check whether you given proper privileges to the user on your current host through which you are trying to connect to MySQL server.

  1. Check your hostname first
  2. Then login into the MySQL through super user like 'root'
  3. Check whether the privileges are provided or not select * from mysql.user where host="host_name"\G;
  4. Give all privileges first, then try to connect again.

grant all on *.* to 'user'@'host_name' identified by 'Password';

I hope this is helpful to you.

0

I spent an entire day banging my head trying to figure this out and it turned out to be that the Windows Network was set as Public instead of Private which blocks all incoming connections. Hope this helps someone.

-1

some hosting providers block by default, the remote access to his MySql servers by security reasons. If you need to unblocking the remote access service tell them for unblocking this service.

Otherwise, test your app locally, as localhost and when this works fine, change the hostname, and so on database parameters in your app, and upload to your web hosting server, thats works fine!!!.

Take care, that your Database design checks with your local database design, this is very important!!!

I hope this is helpful to you.

  • 2
    Do you think they only block every second attempt? – dezso Sep 14 '15 at 16:10
-1

Two things to add for mariadb users:

1) the my.cnf is for us too => there i found the bind-address = 127.0.0.1 line

2) you have to restart the service after changing the my.cnf file

Hope this helps

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.