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

In this article, we will cover the most common reasons of Your PHP installation appears to be missing the MySQL extension which is required by WordPress error, and how it can be fixed.

Disabled extensions in Select PHP version

MySQL extension refers to the PHP extension that is required for WordPress websites to communicate with the database. Thus, the first point to investigate is to check the PHP extensions enabled for your account.

For this purpose, log into your cPanel account and go to the Select PHP Version menu:

Find mysqli (for PHP version 7.0 and higher) and mysql (for PHP version 5.6 and lower) and make sure they are checked:

Custom PHP version

In case the required extension is enabled in your Select PHP Version menu, it is required to check if a separate PHP version is enabled for your website.

This can be done in the following way:

1. Navigate to the cPanel File Manager menu:

2. Find the .htaccess file for the addon domain in question. The steps for how to find it can be located here.

3. Make sure that the correct SetHandler directive is present there. You can check the code for Apache and LiteSpeed servers here.

NOTE: In case your PHP was changed before the migration to LiteSpeed web server, your rule for Apache web server will not work and it will be required to change the rule to the LiteSpeed version.

php.ini configuration file

When a different PHP version is set for the domain, all the PHP extensions should be enabled manually in the php.ini file. Thus, it is required to enable mysql and mysqli extensions in your configuration file. For this purpose:

1. Navigate to the cPanel File Manager menu:

2. Proceed to the public_html folder and press Edit button on the php.ini file:

3. Add the following lines to the file:

It is possible to check if your PHP configuration includes mysql or mysqli extension by setting up a phpinfo function as described here

Once the file is created, access your phpinfo page and look for  mysql or mysqli section:

WordPress and PHP incompatibility

Some old WordPress versions are designed to work with the mysql PHP extension that is available with PHP 5.6 and lower. In case your website is based on an outdated WordPress and the current PHP version is 7.0 or higher, it will be required to either change your PHP version to a lower one or upgrade the WordPress installation so it becomes compatible with the current PHP version set for your website.

You can check how to change the PHP version here.

That's it!

Need any help? Contact our HelpDesk

16810 times

Need help? We're always here for you.