1

I'm a bit puzzled when I after some time did another Wordpress install.

I'm using a standard Apache + PHP 7 combination (even under version control) and after checking out 4.6.1 of Wordpress (the tagged version from the Github SVN mirror, the official Git-ified version) the installer greets me in the second step with the obvious error message that the mysql extension is missing in the following form:

Fatal error: Uncaught Error: Call to undefined function mysql_connect() in /wp-includes/wp-db.php:1561 Stack trace:
#0 /wp-admin/setup-config.php(276): wpdb->db_connect()
#1 {main} thrown in /wp-includes/wp-db.php on line 1561`

I'm a bit puzzled that the current Wordpress version still is based on the (outdated) php-mysql extension.

Maybe I'm missing some configuration setting, even the origin Ezsql class was able to deal with different database backends ca. 15 years ago and as wpdb is forked from it, maybe there is still a leftover to use php-mysqli which is more common nowadays (and should have been straightforward to port to). But perhaps this is beating a dead horse, so I need some feedback for a better orientation.

It's just that from the error message it sounds like mysql is still required, however I hope that's not the whole truth. The Wordpress system requirements do not share any information about the required PHP extensions and from these documented requirements it is that I'm matching them perfectly.

I've been running phpcompatinfo to find out more and the result is mixed, it looks like that mysqli is supported (or at least could be an option):

Extensions Analysis https://github.com/WordPress/WordPress

    Extension  Matches REF        EXT min/Max PHP min/Max     PHP all 
    Core               Core       7.0.2       7.0.2                   
    PDO                PDO        5.1.0       5.1.0                   
[...]
    memcache           memcache   0.2         4.3.3                   
 C  mysql              user       5.2.3       5.2.3                   
 C  mysqli             user       5.0.0       5.0.0                   
 C  mysqlnd            user                   4.0.0                   
 C  openssl            user       5.3.0       5.3.2                   
[...]
    Total [41]                                7.0.2 => 5.6.23         

Related questions:

5

WordPress will use MySQLi when it can or unless you tell it not to. Unfortunately if WP doesn't see a mysqli_* function, it will assume that you want to use mysql_*.

There is some logic that will fall back to plain, old mysql_*, but, from your stack trace, that's not what's happening.

You don't mention what OS you're running on, but I'd guess that the php70-mysql package was not installed. Ubuntu and things like the ondrej/php PPA won't include the various mysql drivers (pdo mysql and mysqli) by default.

  • The mysqli extension was missing, I added it to the container and now the setup continues. Thanks for the clarification. – hakre Sep 27 '16 at 22:19
0

To add to what @chrisguitarguy said, mysql extension was deprecated at php 7.0 (or was it 5.6? not important here), in favor of mysqliextension. As chris said, wordpress tries to detect if you have msqli installed and use it, and in case the detection fails it will try to use mysql. The error you got indicates that you don't have mysqliinstalled or configured.

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.