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:
-
Install will not load: PHP does not have MYSQL installed
-
Your PHP installation appears to be missing the MySQL extension which is required by WordPress
2 Answers
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.