Hello everyone, when working on a client’s Woocommerce website I found the Error: Your PHP installation appears to be missing the MySQL extension which is required by WordPress. This is a very rare error, and it usually only happens with very old PHP versions.
In the previous tutorial, we learned how to fix WooCommerce Gateway PayPal Checkout requires cURL to be installed on your server.
In this tutorial, I will guide you how to install the missing MYSQL Extension to fix this error.
- Cause of the error
- Before dealing with the error
- Fix the error on shared hosting running on Cpanel/Directadmin
- Fix the error on VPS/Dedicated server with ssh access
- Wrapping up
Cause of the error
This error happens when the current PHP version is missing the MySQL extension package which is required when installing WordPress.
To check if php-mysql extension is installed on your site, create a check.php file with the following code:
<?php phpinfo(); ?>
Next, upload this file to the root folder of your website and go to yourwebsite.com/check.php and see the outcome at mysqldnd section.
If it’s not installed, we will fix this error by installing the required package.
Before dealing with the error
Remember to upgrade WordPress to the latest version.
You can get latest version of WordPress on https://wordpress.org or directly upgrade from WordPress admin dashboard
Sometime upgrading wordpress will immediately fix this error. In case you are running on the latest wordpress version and the error is still not fixed, proceed to next step.
On Cpanel go to SOFTWARE section and choose Select PHP version tool
Next, select all mysql extensions
With this new version of Cpanel, the extension will be installed automatically after each click
Now refresh your website to see if the error is fixed
If your website is running on PHP5, I strongly recommend upgrade to php7 for security improvement and faster website load speed. Also, if you are facing the error Your PHP installation appears to be missing the MySQL extension which is required by WordPress, upgrade to PHP7 will immediately solve it because PHP7 has many built-in extensions.
In Cpanel admin section, you can easily swap PHP version with Select PHP version tool
You can do the same with Directadmin.
Fix the error on VPS/Dedicated server with ssh access
SSH to your server and use the following commands
Step 1: Check php version running on your server
Step 2: Install the required mysql extension (use command according to PHP version)
If you website is running on PHP 7 => use the following command
Ubuntu + PHP 7
apt-get update apt-get install php7.0-mysql service apache2 restart
Centos + PHP 7
yum update yum install php70w-mysql service httpd restart
If you website is running on PHP 5 => use these command lines
Ubuntu + PHP 5
apt-get update apt-get install php-mysql service apache2 restart
Centos + PHP 5
yum update yum install php-mysql service httpd restart
Step 3: Enable php mysql extension in php.ini file
Edit php.ini file and add the following line
extension = mysql.so extension=php_mysql.dll
To find path to Php.ini file use the following command
php -i | grep "Loaded Configuration File"
Normally, you can find php.ini in
- Centos: /etc/php.ini
- Ubuntu: /etc/php/7.0/apache2
Finally, restart apache to apply changes.
service apache 2 restart
Service httpd restart
WordPress is the most stable opensource CMS at the moment. It’s not common to see error while using WordPress.
In this tutorial, I mentioned all the steps that you can follow to fix the error Your PHP installation appears to be missing the MySQL extension which is required by WordPress.