fbpx

How to fix “missing the MYSQL Extention which is required by WordPress” error

The error

If you run into the following error within your WordPress installation:

“Your php installation appears to be missing the mysql extension which is required by wordpress.”

Then you are experiencing a fairly common WordPress error caused by incorrect PHP configurations.

Similar to your Chrome browser, PHP also works with extensions. For PHP to interact with a MYSQL database it requires the PHP MYSQL extension installed.

Newer PHP versions use a slightly different extension called MYSQLI or PDO_MYSQL. Whereas older PHP versions use an older PHP extension to connect to MySQL.

The “missing the MySQL extension” error in WordPress typically occurs when the PHP MySQL extension is not installed or enabled on the web server. To fix this error, you will need to do one or both of the following:

  1. Install the PHP MySQL extension: This can typically be done by running a command such as apt-get install php-mysql (on Ubuntu) or yum install php-mysql (on Fedora) in your terminal.
  2. Enable the PHP MySQL extension: Once the extension is installed, you will need to enable it in your PHP configuration file. This is typically located at /etc/php/php.ini or /etc/php.ini. Open the file in a text editor and look for the line ;extension=mysqli (or ;extension=mysql for older versions of PHP). Remove the semicolon at the beginning of the line to uncomment it, then save and close the file.

You will need to restart the web server after making these changes for them to take effect.

If this hasn’t fixed your issue, continue reading.

How do I fix the error?

Step 1: Changing PHP version

The first step you should take is to upgrade your PHP version. PHP version 7.3, 7.2, 7.1, 7.0 & 5.6 is at the end of life and deprecated. You should avoid using these PHP versions due to security vulnerabilities and performance issues, Instead upgrade to PHP 7.4 or to the latest PHP 8.0 which also provides additional performance benefits.

If you are using PHP 7.4+ and still seeing the error “Your PHP Installation Appears to Be Missing the MySQL Extension Which Is Required by WordPress” then move on to the next step.

Step 2: Installing missing PHP MySQL extension

If you are still seeing the error after upgrading PHP, chances are you are not hosted with Koerge or any reputable web hosting provider. Instead, you are likely setting up your own VPS/Cloud server.

First thing to do is create an info.php file with the following code:

<?php
phpinfo();
?>

Once this is done, save and open the file from your browser. This will give you a full breakdown of your current PHP settings, here you will confirm what PHP is currently being used as well as see all active PHP extensions. You can use Control + F to search for MySQL and attempt to identify if the extension is active.

Unfortunately with so many different ways of setting up your own VPS/Cloud server it is almost impossible to cover all scenarios under a single article. However if you cannot find any of the two MYSQL extensions:

  • MYSQLi
  • PDO_MYSQL

Chances are you will need to install one in order for the error “Your PHP Installation Appears to Be Missing the MySQL Extension Which Is Required by WordPress” to be fixed.