我有一个配置了连接池的 Java 应用程序。我已确保应用程序正确终止连接。
但是,当我在 mysql 命令行上运行此命令时-
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 |
+--------------------------+-------+
当连接从客户端终止时,为什么mysql保持打开状态?
文件的内容my.cnf
是(注释和不重要的部分省略) -
[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
根据MySQL 文档,Connections 状态变量显示“与 MySQL 服务器的连接尝试次数(成功与否)。” 这意味着它不代表当前打开的连接,而是自服务器启动以来的所有连接尝试。
再次根据MySQ 文档,显示当前打开连接数的变量是 Threads_connected。