Posts Tagged ‘command to check whether mysql drops connects’

Check is MySQL dropping connections or how to check drop out SQL problems and debug problems with slow queries

Thursday, October 26th, 2017

mysql-dropping-connections-how-to-check-command-drop-out-sql-problems-and-debugging-slow-queries

If you have migrated a website or you recently upgraded MySQL and you face occasional problems with dropped connections to remote Web site or application it is likely that the problem is rooted either in Apache being unable to handle multiple connections, e.g. you will get a lot of 503 errors in log or MySQL dropping connections due to someout or MySQL / PHP bug that occurs after packages upgrade.

So how to check is MySQL dropping connections?

Use below command one liner shell script and check for Aborted conncetions a relatively high number is indication MySQL is dropping connections from PHP script or local / remote application such as SOAP or XSLT connects.
 

# echo 'show global status' | mysql -u root -p |grep -i connect
Enter password:
Aborted_connects    710
Connections    49537
Max_used_connections    76
Ssl_client_connects    0
Ssl_connect_renegotiates    0
Ssl_finished_connects    0
Threads_connected    1

Another indicator for MySQL dropping connections is if you find MySQL to have many slow queries, that would mean the slow queries won't be processed on time and there will be consequential connection drop outs.
 

# echo 'show global status' | mysql -u root -p |grep -i slow
Enter password:
Slow_launch_threads    0
Slow_queries    120237


If you find any you can use some MySQL / MariaDB monitoring script such as (mytop / mtop – for more on monitoring MySQL queries in real time I recommend you check out my previous article Monitoring MySQL queries and debugging performance (slow queries))