Support Engineers at Bobcares manage thousands of WordPress sites of web designers, digital marketers, online publishers, web hosts and more.

In these sites, this error usually comes up after a recent migration:

Your PHP installation appears to be missing the MySQL extension which is required by WordPress.

Today we’ll take a look at the top 5 reasons for this error, and how to fix them.

 

1. PHP’s MySQL extension not installed

PHP’s ability to send SQL commands to MySQL comes from an additional module called MySQL extension. In some default operating system setup, this extension might not be present.

To check if your PHP has MySQL support, put the following code into a file called info.php in your site, and access it from a browser.

<?
phpinfo();
?>

It should show a MySQL section like this:

If not, you may have to install MySQL extensions.

In Ubuntu servers, use the command:

# apt-get install php5-mysqlnd

In RedHat compatible servers, use the command:

# yum install php-mysql

[ Website errors can drive your customers away. Click here to get an experienced server admin to monitor & maintain your server 24/7. ]

 

2. PHP extension directory mis-configured

In some websites, especially those that were recently migrated, or in a newly setup VPS, the “extension_dir” is sometimes misconfigured.

This directory stores all the PHP libraries, and if not set correctly, PHP cannot execute those functions.

To fix this, first locate which PHP.ini file is being loaded by your website. For this, put the following code into a file called info.php, and access it from a browser.

<?
phpinfo();
?>

Look for the line called “Loaded Configuration File”. The file path noted there is the actual location to the PHP configuration file.

Now, look for the entry called “extension_dir“. It should either be commented, or it should have the correct path to PHP extensions. It should never be left blank.

If you are not sure, just comment the line, and restart the web server.

3. Wrong file name/path for MySQL.so or MySQL.DLL

Some websites have custom configured PHP configuration (php.ini) files. These files will not be automatically updated by system programs during an upgrade or a migration.

We’ve seen typing mistakes and wrong extension directory paths put in the custom configuration files.

If you have a custom configuration file, it is best to comment out the lines that have the following:

; extension=mysql.so

; extension_dir=/path/to/extensions/

[ A single misconfiguration can break your site! Our support engineers perform flawless upgrades and keep your site stable & secure. Click here to know more. ]

 

4. Missing php-mysqlnd-ms packages in Ubuntu servers

In the later Ubuntu operating systems, MySQL’s native drivers are used instead of the old PHP libraries.

In these systems, if the package php5-mysqlnd-ms is not installed, it can result in this error.

So, to fix it use this command:

# apt-get install php5-mysqlnd-ms

[ Don’t wait till your website goes down. Protect your site with timely upgrades and maintenance. Click here to know more. ]

 

5. Incorrect PHP config via suPHP_ConfigPath

In servers where suPHP is enabled, custom PHP configuration files are loaded through suPHP_ConfigPath.

These PHP config files sometimes contain conflicting entries on MySQL extensions. This is especially true in the case of shared servers where Multi-PHP option is available (eg. cPanel/WHM and Plesk servers).

So, if suPHP_ConfigPath is defined in .htaccess of virtual host configuration of a website, try commenting it out to see if the error is resolved. If so, then the custom PHP.ini should be reviewed and conflicting entries should be removed.

 

In short..

Your PHP installation appears to be missing the MySQL extension which is required by WordPress.” is a common error faced by websites that are recently migrated or PHP upgrade done. Here we’ve seen the top 5 causes for this error, and how to resolve them.

Bobcares helps online businesses of all sizes achieve world-class security and uptime, using tried and tested solutions. If you’d like to know how to make your server more reliable, we’d be happy to talk to you.