Database Reference
In-Depth Information
PersistentConnections
Another important parameter (which is not server-specific but applies to all server
definitions) is
$cfg['PersistentConnections']
. For every server we connect to
using the
mysql
extension, this parameter, when set to
TRUE
, instructs PHP to keep
the connection to the MySQL server open. This speeds up the interaction between
PHP and MySQL. However, it is set to
FALSE
by default in
config.inc.php
because
persistent connections are often a cause of resource depletion on servers. So you
will find MySQL refusing new connections. For this reason, the option is not even
available for the
mysqli
extension. Hence they setting it to
TRUE
here would have no
effect if you are connecting with this extension.
connect_type, socket and port
Both the
mysql
and
mysqli
extensions automatically use a socket to connect to
MySQL if the server is on
localhost
. Consider this configuration:
$cfg['Servers'][$i]['host'] = 'localhost';
$cfg['Servers'][$i]['port'] = '';
$cfg['Servers'][$i]['socket'] = '';
$cfg['Servers'][$i]['connect_type'] = 'tcp';
$cfg['Servers'][$i]['extension'] = 'mysql';
The default value for
connect_type
is
tcp
. However, the extension will use a socket
because it concludes that this is more efficient as the
host
is
localhost
. So in this
case, we can use
tcp
or socket as the
connect_type
. To force a real tcp connection,
we can specify
127.0.0.1
instead of
localhost
in the
host
parameter. Because the
socket
parameter is empty, the extension will try the default socket. If this default
socket, as defined in
php.ini
, does not correspond to the real socket assigned to the
MySQL server, we have to put the socket name (for example,
/tmp/mysql.sock
) in
$cfg['Servers'][$i]['socket']
.
If the hostname is not localhost, a tcp connection will occur—here, on the special port
3307. However, leaving the port value empty would use the default 3306 port:
$cfg['Servers'][$i]['host'] = 'mysql.mydomain.com';
$cfg['Servers'][$i]['port'] = '3307';
$cfg['Servers'][$i]['socket'] = '';
$cfg['Servers'][$i]['connect_type'] = 'tcp';
$cfg['Servers'][$i]['extension'] = 'mysql';
Search WWH ::
Custom Search