I have built PHP 7 with a configuration that worked for a previous version of PHP.
Now my WordPress websites get the message:
Your PHP installation appears to be missing the MySQL extension which is required by WordPress.
Other websites using mysqli do work. What am I missing?
I’ve also included all .so files with mysql in the name:
extension=dba.so
extension=mysql.so
extension=mysqli.so
extension=mysqlnd_mysql.so
extension=mysqlnd_mysqli.so
extension=mysqlnd.so
extension=pdo.so
extension=pdo_mysql.so
extension=pdo_odbc.so
extension=odbc.so
PHP 7 has removed mysql_* completely.
You need to use PDO or mysqli. WordPress seems not to support this.
mysql_*
functions got deleted in PHP 7.0 update your code to mysqli or PDOAlso take a look at prepared statements if you are handling user input. To reduce the chance of SQL injections
An example of mysqli connection string:
An example of pdo connection string:
Note:
That mysqli example handles a connection error
As has been mentioned elsewhere, the
ext/mysql
functions have been removed. We’ve been talking about this for some time.If you’re hell-bent on putting them back in, you can add them back to PHP 7 by using the ext/mysql PECL Library
It’s important to note that WordPress 3.9 or later supports mysqli
Check if the WordPress still using the Mysql extension that was removed in PHP7.
http://php.net/manual/en/migration70.removed-exts-sapis.php
The Mysqli and PDO extensions were kept. This is the reason your other websites are working.
This issue is caused by php 7.1.0-dev.
I built another one with the same configuration version 7.0.0 and the issue was resolved.
This has nothing to do with WordPress since it will automatically try to use MySQLi when MySQL is not found. At least in WP 4.4.
On Ubuntu, I fixed this error by running
And then restarting my server (caddy, but you might be using apache or nginx).
source