Question

I use JDBC to connect to MySQL. When it’s at localhost:3306, everything is OK.

But when I move my application to another computer in the intranet, and use <Intranet-IP>:3306 to connect to the MySQL database, it takes about 1 minute to connect to MySQL successfully. What’s up with this?

Was it helpful?

Solution

Well it could be a DNS problem. You can disable DNS host name lookups by starting mysqld with the --skip-name-resolve option in the configuration file.

Read here for more details: http://dev.mysql.com/doc/refman/5.0/en/host-cache.html

OTHER TIPS

The --skip-name-resolve worked great for me.

To make it permanent, I just add this line at the end of file my.ini in the [mysql] section:

skip-name-resolve

And voilá! Transactions now fly!

For me it was this solution I found here, If IP6 connectivity is enabled, connection to "localhost" may be slow, instead use the ip address, 127.0.0.1. This worked for me.

my mysql slow to connect problem was solved by this solution

firewalls, Internet, routing etc etc slows down your connection.

You should put your database on a intra net instead. Keep it local and behind your big firewall. You can of course have firewall and security between computers. I'd recommend that you didn't expose your mysql database connection to the Internet unfiltered that way.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top