Thursday, 12 March 2015

Mysqli is not working properly

In plesk server, I have installed the php 5.6 as secondary php.
Then if I have try to use "mysqli" dbtype in Joomla site, I got error such as database connection error.

Cause:
-----------
It seems mysqli uses mysqlnd API in secondary php,

mysqli
Client API library version => mysqlnd 5.0.11-dev - 20120503 - $Id: 3c688b6bbc30d36af3ac34fdd4b7b5b787fe5555 $
mysqli.allow_local_infile => On => On
mysqli.allow_persistent => On => On
mysqli.default_host => no value => no value
mysqli.default_port => 3306 => 3306
mysqli.default_pw => no value => no value
mysqli.default_socket => no value => no value
mysqli.default_user => no value => no value
mysqli.max_links => Unlimited => Unlimited
mysqli.max_persistent => Unlimited => Unlimited
mysqli.reconnect => Off => Off
mysqli.rollback_on_cached_plink => Off => Off

By default mysqli uses mysql API in main php,

mysqli
MYSQLI_SOCKET => /var/run/mysqld/mysqld.sock
mysqli.allow_local_infile => On => On
mysqli.allow_persistent => On => On
mysqli.default_host => no value => no value
mysqli.default_port => 3306 => 3306
mysqli.default_pw => no value => no value
mysqli.default_socket => no value => no value
mysqli.default_user => no value => no value
mysqli.max_links => Unlimited => Unlimited
mysqli.max_persistent => Unlimited => Unlimited
mysqli.reconnect => Off => Off

Solution:
--------------
I suspect it might tried to using mysqlnd, Hence I changed the value from
mysqli.default_socket = " " to mysqli.default_socket = /var/run/mysqld/mysqld.sock in respective php.ini[Used secondary php 5.6 php.ini here].
By default if we didn't give anything in this value, it automatically takes the default socket. Here I think mysqli tried to take mysqlnd socket. So I manually changed it to mysql socket.
Then the issue was fixed.

No comments:

Post a Comment