I have a shell script to execute some query in mysql database and process the results and send mail accordingly. The script runs 24X7 in each 15 minutes. Inside the shell script I am simply connecting to the db using the command 'mysql -uusername -ppassword database -s -N -e "Some query goes here"
All I want to know is that, does this script have to do something with the db connection leak, since I am executing this script forever. When I execute the following query I can see that each time the Connections value goes up by one in each 15 minutes. show status like '%Con%';
+----------------------------------------+-------+
| Variable_name | Value |
+----------------------------------------+-------+
| Aborted_connects | 4 |
| Com_show_contributors | 0 |
| Connections | 804 |
| Max_used_connections | 152 |
| Performance_schema_cond_classes_lost | 0 |
| Performance_schema_cond_instances_lost | 0 |
| Ssl_client_connects | 0 |
| Ssl_connect_renegotiates | 0 |
| Ssl_finished_connects | 0 |
| Threads_connected | 14 |
+----------------------------------------+-------+
Does it crash at some point of time?. Because the value never comes down. I know the value indicates the total number of connections present to the db. However Max_used_connections remains same. Or is there a way to close the db connection from shell script?
As MySQL documentation on the connections server status variable says:
The number of connection attempts (successful or not) to the MySQL server.
So, this is a statistical number showing the number of connection attempts since the last restart of the MySQL server.
The threads_connected status variable shows the number of currently open connections (14 in your case). If this status variable equals to the max_connections server SYSTEM variable , then you will start receiving too many connections error message.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.