Why is connecting to MySQL server so slow?

MemoryLeak picture MemoryLeak · Aug 18, 2009 · Viewed 59.5k times · Source

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?

Answer

Davide Ungari picture Davide Ungari · Aug 18, 2009

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