Reputation: 1255
I just want to know how can i close all open connections from mysql and will it increase speed of my web site.
please take a look of mysql status output
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
I am using code-igniter v3 for my project with the following db settings in 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
);
Upvotes: 0
Views: 1738
Reputation: 11
You shouldn't have to do anything.
I believe Codeigniter/MySQL will take care of closing connections for you as you do not have persistent connections enabled ('pconnect' => FALSE) this will allow connections to be closed automatically.
https://codeigniter.com/user_guide/database/connecting.html#manually-closing-the-connection
While CodeIgniter intelligently takes care of closing your database connections, you can explicitly close the connection.
$this->db->close();
Upvotes: 1