Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is connecting to MySQL server so slow?

Tags:

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?

like image 797
MemoryLeak Avatar asked Aug 18 '09 09:08

MemoryLeak


People also ask

Why MySQL server is slow?

If your database is being used in high volumes, this can slow the database down. When there are too many queries to process at once, the CPU will bottleneck, resulting in a slow database.

Why MySQL server is not connecting?

normally means that there is no MySQL server running on the system or that you are using an incorrect Unix socket file name or TCP/IP port number when trying to connect to the server. You should also check that the TCP/IP port you are using has not been blocked by a firewall or port blocking service.

How do I know if MySQL is slow?

If you suspect that its a MySQL query, try inspecting the MySQL Slow Query Log. The log will help you identify queries that take long time to execute. You can then copy-paste the query text into a MySQL query session, execute it and observe the CPU usage.


1 Answers

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

like image 85
Davide Ungari Avatar answered Sep 30 '22 09:09

Davide Ungari