1

I am trying to complete an install of wordpress using php5-fpm and nginx, with a database on a remote server. However, wordpress doesn't recognize the existence of mysql to allow me to connect to the remote database.

Code to check whether the mysql extension is loaded, from php, says the extension isn't loaded:

<?php
var_dump(extension_loaded('mysql'));
mysql_connect();

Results in:

bool(false)
PHP message: PHP Fatal error:  Call to undefined function mysql_connect() in /path/www/check.php on line 3

Yet everywhere seems to indicate that the pieces that should be necessary (php5-fpm, php5-mysql, mysql-client, wordpress) are in place, just the local server is necessarily -NOT- running mysql-server because that's on the remote server.

So what should I be looking for in order to try to get the extension_loaded('mysql') to be in the right state, along with everything else?


The output of the various dependencies installed follows below:

apt-cache policy mysql-client
mysql-client:
  Installed: 5.5.43-0ubuntu0.14.04.1
  Candidate: 5.5.43-0ubuntu0.14.04.1
  Version table:
 *** 5.5.43-0ubuntu0.14.04.1 0
        500 http://mirror.rackspace.com/ubuntu/ trusty-updates/main amd64 Packages
        500 http://mirror.rackspace.com/ubuntu/ trusty-security/main amd64 Packages
        100 /var/lib/dpkg/status
     5.5.35+dfsg-1ubuntu1 0
        500 http://mirror.rackspace.com/ubuntu/ trusty/main amd64 Packages
 apt-cache policy mysql-server
mysql-server:
  Installed: (none)
  Candidate: 5.5.43-0ubuntu0.14.04.1
  Version table:
     5.5.43-0ubuntu0.14.04.1 0
        500 http://mirror.rackspace.com/ubuntu/ trusty-updates/main amd64 Packages
        500 http://mirror.rackspace.com/ubuntu/ trusty-security/main amd64 Packages
     5.5.35+dfsg-1ubuntu1 0
        500 http://mirror.rackspace.com/ubuntu/ trusty/main amd64 Packages

php5-mysql is also installed.

My wordpress version:

 wp core version --extra
WordPress version: 4.1.1
Database revision: 30133
TinyMCE version:   4.107 (4107-20150118)

Php5 version:

php --version
PHP 5.5.9-1ubuntu4.9 (cli) (built: Apr 17 2015 11:44:57) 
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2014 Zend Technologies
    with Zend OPcache v7.0.3, Copyright (c) 1999-2014, by Zend Technologies

The php5-fpm config

php5-fpm -i | grep mysql
/etc/php5/fpm/conf.d/20-mysql.ini,
/etc/php5/fpm/conf.d/20-mysqli.ini,
/etc/php5/fpm/conf.d/20-pdo_mysql.ini,
mysql
MYSQL_SOCKET => /var/run/mysqld/mysqld.sock
MYSQL_INCLUDE => -I/usr/include/mysql
MYSQL_LIBS => -L/usr/lib/x86_64-linux-gnu -lmysqlclient_r 
mysql.allow_local_infile => On => On
mysql.allow_persistent => On => On
mysql.connect_timeout => 60 => 60
mysql.default_host => no value => no value
mysql.default_password => no value => no value
mysql.default_port => no value => no value
mysql.default_socket => /var/run/mysqld/mysqld.sock => /var/run/mysqld/mysqld.sock
mysql.default_user => no value => no value
mysql.max_links => Unlimited => Unlimited
mysql.max_persistent => Unlimited => Unlimited
mysql.trace_mode => Off => Off
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 => /var/run/mysqld/mysqld.sock => /var/run/mysqld/mysqld.sock
mysqli.default_user => no value => no value
mysqli.max_links => Unlimited => Unlimited
mysqli.max_persistent => Unlimited => Unlimited
mysqli.reconnect => Off => Off
PDO drivers => mysql, pgsql
pdo_mysql
pdo_mysql.default_socket => /var/run/mysqld/mysqld.sock => /var/run/mysqld/mysqld.sock
  • 1
    I have set up and ran you are trying. I did not have trouble getting MySQL to boot though. Ultimately, this has nothing to do with WordPress though. The problem occurs before WordPress gets involved. I'd suggest you try another Stack. – s_ha_dum Apr 29 '15 at 14:20
  • @s_ha_dum Yeah, I thought that it was wordpress related because of how wordpress was checking for mysql in a certain specific way, but it was actually an "old" instance of php5-fpm that sudo service php5-fpm restart wasn't aware of, and which had to be killed. – Kzqai Apr 29 '15 at 14:50
  • Notice that the PHP mysqli extension is now recommended over the deprecated mysql extension. – birgire Apr 29 '15 at 14:58
1

Ah, my problem ended up stemming from an issue with php5-fpm. Essentially, there were php5-fpm services running that were "old" and thus when I tried to access mysql from the web, it wasn't detected. But when I tried to access it via cli, it was detected. That narrowed it down to php5-fpm for me, and then I had to do:

sudo killall php5-fpm
sudo service php5-fpm start

And voila, the web side started recognizing mysql just fine!

I'm still not sure what exactly led to a php-fpm process that the service wasn't aware of to restart, but it's something to watch out for.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.