【发布时间】:2018-02-02 11:08:31
【问题描述】:
我只想知道如何关闭来自 mysql 的所有打开的连接,它会提高我网站的速度。
请看一下mysql状态输出
Variable_name Value
Aborted_connects 1
Connection_errors_accept 0
Connection_errors_internal 0
Connection_errors_max_connections 0
Connection_errors_peer_address 0
Connection_errors_select 0
Connection_errors_tcpwrap 0
Connections 252
Max_used_connections 6
Performance_schema_session_connect_attrs_lost 0
Ssl_client_connects 0
Ssl_connect_renegotiates 0
Ssl_finished_connects 0
Threads_connected 1
我正在为我的项目使用 code-igniter v3,并在 database.php 中使用以下数据库设置
$active_group = 'default';
$query_builder = TRUE;
$db['default'] = array(
'dsn' => '',
'hostname' => 'localhost',
'username' => 'root',
'password' => '#######',
'database' => '#######',
'dbdriver' => 'mysqli',
'dbprefix' => '',
'pconnect' => FALSE,
'db_debug' => (ENVIRONMENT !== 'production'),
'cache_on' => FALSE,
'cachedir' => '',
'char_set' => 'utf8',
'dbcollat' => 'utf8_general_ci',
'swap_pre' => '',
'encrypt' => FALSE,
'compress' => FALSE,
'stricton' => FALSE,
'failover' => array(),
'save_queries' => TRUE
);
【问题讨论】:
-
您的输出状态仅显示一个
Threads_connected。如果您担心Connections统计信息,请不要担心。这是连接到 MySQL 服务器的尝试次数(成功与否)。换句话说,在 252 次连接尝试中,当前只有一个连接。如果这是手机通话记录,则意味着您接到了 252 个电话,其中一个仍在进行中。
标签: codeigniter mysqli