How To

Fix: Your PHP installation appears to be missing the MySQL extension

As part of the regular website maintenance activity, I upgraded PHP version of WordPress website and suddenly  website started showing below error message:

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

The error clearly hinted that issue was related with MySQL and PHP. I always check the PHP information when suspect something is related to PHP as it provides detail information about PHP version, server information, configuration, modules, environment & variables. To find out how to create PHP information page, checkout the official PHP link here.

After going through the PHP information, I noticed that MySQLi extension was enabled and not MySQL. After doing some research I found out that MySQL extension is deprecated since PHP 5.5.0 and MySQLi extension is added in PHP 5.5. But the backward compatibility for MySQL is still available. That's why I was not getting any error for previous PHP 7.1 version which had MySQL module/extension enabled and not MySQLi.

Now the question is, should I contact hosting provider for to enable MySQL extension? The answer is not all since there is an option in WordPress to stop using MySQL extension and switch to MySQLi.

By default MySQL extension is used WordPress but we don't notice unless we get an error. If you have MySQLi extension enabled in PHP then it is very easy to tell WordPress to use MySQLi extension instead of MySQL.

Steps to enable MySQLi extension in your WordPress:

  • Create a backup of existing wp-config file.
  • Open the wp-config file in edit mode.
  • Add the below constant before That's all, stop editing! Happy blogging line and make sure its value is set to false.
define('WP_USE_EXT_MYSQL', false);

Setting WP_USE_EXT_MYSQL to false means you are telling WordPress to use MySQLi extension instead of MySQL.

  • Refresh the browser cache and reload the website.

Do let me know if this solution works for you in the comment section...

Abhijit Sandhan

Loves Open Source, Blogging, Traveling, Hiking and sharing Knowledge!

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Back to top button