Mysql not closing connections

connectivitymax-connectionsMySQL

I have a Java application that configured with a connection pool. I have ensured that the application terminates the connections properly.

However when I run this command on mysql command line –

show status like '%onn%';

+--------------------------+-------+
| Variable_name            | Value |
+--------------------------+-------+
| Aborted_connects         | 2     |
| Connections              | 72    |
| Max_used_connections     | 10    |
| Ssl_client_connects      | 0     |
| Ssl_connect_renegotiates | 0     |
| Ssl_finished_connects    | 0     |
| Threads_connected        | 2     |
+--------------------------+-------+

Why does mysql keep the connections open when they have been terminated from the client?

The contents of my.cnf file are (comments and unimportant sections omitted) –

[client]
port        = 3306
socket      = /var/run/mysqld/mysqld.sock

[mysqld]
user        = mysql
pid-file            = /var/run/mysqld/mysqld.pid
socket      = /var/run/mysqld/mysqld.sock
port        = 3306
basedir     = /usr
datadir     = /var/lib/mysql
tmpdir      = /tmp
lc-messages-dir = /usr/share/mysql
lower_case_table_names = 1
skip-external-locking

key_buffer      = 16M
max_allowed_packet  = 16M
thread_stack    = 192K
thread_cache_size   = 8

myisam-recover      = BACKUP

query_cache_limit   = 1M
query_cache_size    = 16M

expire_logs_days    = 10
max_binlog_size     = 100M

Best Answer

According to MySQL documentation the Connections status variable shows "The number of connection attempts (successful or not) to the MySQL server." This means that it does not represent current open connections, but all connection attempts since the server has been started.

The variable showing number of current open connections, again according to MySQ docs, is Threads_connected.