How to Fix “Your PHP Installation Appears to Be Missing the MySQL Extension Which Is Required by WordPress” Error
“Your PHP Installation Appears to Be Missing the MySQL Extension Which Is Required by WordPress”
Are you getting this WordPress error when trying to access your WordPress site?
It can be downright frustrating, I know! It’s your website – your home on the internet – and all of a sudden, you are denied access to it!
The worst thing in this scenario is when you don’t know what’s causing the error and how you’re going to fix the damn thing to get access to your own site.
Or even worse is when you can’t even figure out if this error message is written in plain English or in some other alien language you can’t decipher.
The Causes – Your PHP Installation Appears to Be Missing the MySQL Extension Which Is Required by WordPress
As dreadful and frustrating as this WordPress error sounds and looks, it’s actually caused by a very simple thing – using outdated versions of PHP and/or WordPress.
If you want to tighten the security of your WordPress site and protect it from hackers, you must keep everything updated, including the core, PHP version, themes, and plugins.
With that said, let’s dive a bit deeper into this particular WordPress bug and try to understand how it creeps up when one of these – PHP or WordPress – is outdated.
In the past, the older versions of PHP (older than 7) used the MySQL extension to connect WordPress to its MySQL database.
Fast forward to today and the newer versions of PHP have deprecated the MySQL extension and instead require MySQLi which the newer versions of WordPress use.
So, this weird bug creeps up when one of these – PHP or WordPress – is outdated. If you’re using an older version of PHP, you’ll need the MySQL extension that might have gone missing if you updated your WordPress core.
If your PHP is up to date, the problem might be with using an older version of WordPress. And the simple solution would be to bring the WordPress core right on track as well.
The Solution: Your PHP Installation Is Missing MySQL Extension Required by WordPress
To fix the problem, you first need to diagnose the error.
And to diagnose the error, you first need to check your PHP version.
Checking your PHP version in WordPress – Which version of PHP are you using?
There are three methods to check your PHP version: via site health tool, cPanel, and via uploading a PHPinfo file in your root directory.
- Checking PHP version via Site Health Tool
- Checking PHP Version via cPanel
- Checking PHP Version via PHPinfo Page
Checking PHP Version via Site Health Tool
You can easily check your PHP version from your WordPress dashboard – simply by navigating to Tools > Site Health and clicking the info tab to check the PHP version.
But what if that irritating bug isn’t letting you access your own familiar dashboard? What’re you supposed to do then?
Checking PHP Version via cPanel
Let’s take you through the process of checking your PHP version through your cPanel first since it’s the safest and simplest way to do so without touching any of your site files.
To check the PHP version from cPanel, login to your cPanel using the credentials provided by your hosting provider.
In your cPanel, navigate to Software > Select PHP Version.
From here, you can actually see which PHP versions are supported by your hosting provider and you can even change your PHP version from here. And you’ll also be able to locate what version you’re currently using.
Checking PHP Version via PHPinfo File
Though most hosting providers allow you to easily figure out your current PHP version from your cPanel, let’s take you through the process of finding out the PHP version by editing your WordPress files – just in case.
Here, it gets a little techie but and we’ll explain in a simple, easy way.
First, create a new text document using a text editor. Open a text editor like Notepad and create a new document. Paste the following code in it.
<?php phpinfo(); ?>
When saving the file, name it phpinfo.php and upload it to the root directory of your WordPress site from your cPanel’s File Manager app.
You basically need to locate the public_html folder and paste the file in that folder. It will be the same folder that contains your wp-config.php file.
Now, open your site in your browser and type /phpinfo.php at the end of your website domain. So it looks something like:
Doing so opens a page that displays information about your current PHP version.
You can find what PHP version you’re using here.
Now, there are two possibilities here. Let’s look at both of them and see how we’re going to solve the issue accordingly.
Diagnosis: Your PHP version is under 7
If you’re using an older version of PHP like PHP 5 or something, it indicates that you’re missing the MySQL extension or your MySQL extension isn’t configured properly.
How to fix the issue?
The simple solution is to update the PHP version and all issues will be automatically resolved.
- How to Upgrade your PHP version
- How to Check for Missing MySQL Extension
- How to Configure MySQL Extension Properly
How to Update Your PHP Version to Fix the Missing MySQL Extension Error in WordPress
How you update your PHP version depends on your hosting provider.
Every hosting provider has different methods and instructions for updating PHP versions.
WordPress has compiled a really useful document here which lists almost all commonly used hosting services with links to their instructions page.
You can simply go to this page, select your hosting provider, and follow their instructions to update your PHP version.
However, it’s extremely important that you create a backup of your site before modifying the PHP version so that if something breaks in the process, you don’t lose everything.
You should also create a staging environment before upgrading the PHP version. PHP updates, though highly recommended, sometimes bring nightmares for website owners. I am talking about errors like the notorious white screen of death or the dreadful 500 error.
It’s common for things to break during the update process. And so, a staging environment protects your live site from havoc. You can update PHP and test your site rigorously before pushing it to Production.
In any case, if things don’t go too well for you during the process of updating, no worries. There is a reason why professional WordPress developers (like us!) exist. Feel free to give us a call!
Check for Missing MySQL Extension
If you want your site to load fast and stay protected from hackers and cyber-attacks (of course you do!) you need to update your server’s PHP version.
Older PHP versions no longer get security updates and have very slow performance, which will affect your WordPress site’s SEO ranking, its user experience, and also pose a big security risk.
However, there are times when the new PHP version would simply not work for you. Maybe you tried it earlier and it broke your site and you had to revert back to the older one.
Maybe you’re using a custom plugin, which is critical for your site’s functionality and that uses the old PHP functions, which means updating your server’s PHP would break the plugin.
Though ideally, you should contact the plugin developers and get the plugin upgraded so it becomes compatible with the new version of PHP, custom WordPress development might not be feasible for you at this time.
In that case, you need to figure out a way that resolves this annoying error without upgrading PHP version.
And so, you need to check if the MySQL extension is installed and if it is, you need to check if it’s configured properly.
To do that, open that same phpinfo.php file in your browser and look for information related to the MySQL extension.
You’ll locate a field titled “Client API Library Version”. If the MySQL extension is installed, you’ll see something like MySQL 5.0.
If you can’t find this information, it probably means the extension is missing and that’s what causing the error.
To solve the problem, the best way is to contact your hosting provider and ask the support staff to install the extension for you.
The MySQL Extension isn’t Configured Properly
If you can locate the version number of the MySQL extension on the PHP info page, it means your MySQL extension is already installed. And so, it probably means the extension isn’t configured properly, which is giving the error.
The most common problem is when the MySQL extension isn’t located in the correct directory, which leads to problems with your PHP file not being able to detect the extension. This leads to the missing extension error.
You have to check the file paths of the PHP configuration file (php.ini) and the extension directory and make sure the extension directory is in the same folder where your php.ini file is located.
To do that, refer to the same PHPinfo page and look for the following fields:
“Loaded Configuration File”
This field shows the file path of the php.ini file, which is the PHP configuration file. Note the file path shown in this field.
And then look down for another field on the same PHPinfo page:
Check the information next to this field and see if the file path listed here matches the path of the php.ini file.
If these two file paths aren’t matching, you’ll need to edit your php.ini file so it links correctly to the extensions directory.
Want to locate php.ini file in your WordPress installation? See this detailed post on where is php.ini in WordPress.
Don’t want to go through all the hassle of troubleshooting? It’s best to get help from professional developers at this point to resolve the issue and speed things up.
Diagnosis: Your PHP version is 7+
If your PHP is up to date, there’s a possibility that you’re running the older version of WordPress. And so, you must update it to give your site a major performance and security boost, besides fixing the WordPress error.
Let’s go through the process of updating WordPress so you can fix this creepy WordPress bug that’s stopping you and your site visitors from accessing all the awesomeness you’ve to offer.
How to Update WordPress Core to Fix the Missing MySQL Extension Error
Updating the WordPress core is actually a simple, straight-forward, and one-click process. But only when you can access your WordPress dashboard!
If you can, you just have to navigate to Updates from your WordPress dashboard and click Update Now to start the updating process.
Before you update WordPress, it’s always a good idea to have a backup in case things go awry.
Now, for the technical part, when you can’t access your dashboard, you’ll need to manually update your WordPress to get rid of the Missing MySQL Extension error.
Here’s what you need to do to update WordPress manually:
- Download the latest WordPress software (a zipped file) from the WordPress.org website.
- Unpack the zipped file, open it and delete the following files:
- The wp-config-sample.php file
- The wp-config.php file
- The wp-content folder
- Upload the remaining files and folder in your WordPress root directory via File Manager in cPanel or by accessing your site’s files via FTP.
- When prompted about duplicate files, allow it to overwrite all files.
When done, your site should be running the latest WordPress version and your issue should be resolved by now.
Summary: Your PHP Installation Appears to Be Missing the MySQL Extension Which Is Required by WordPress
To sum up, the missing MySQL extension error is caused when either PHP or WordPress is upgraded but the other isn’t.
The easiest solution is to look for the version number of your PHP and see if it’s 7+. And then, make sure WordPress is running the latest version too, and upgrade whichever isn’t up to date.
It gets a bit complicated, however, when updating PHP isn’t feasible for you at the moment. This happens when you use a plugin that uses the old PHP functions. And so, if you upgrade your PHP version, it will likely break the plugin functionality.
Hence, you should take a different approach and fix the error by proper PHP configuration and installing the necessary extensions.
Read more how-to’s and tutorials related to WordPress Development
- How to Edit WordPress Code – HTML, CSS, PHP (Easy Guide)
- How to Get the WordPress Post ID
- How to Set Up a PayPal Donation Button on WordPress
- How to Fix WordPress Stuck in Maintenance Mode
- How to Embed iFrame Code on Your WordPress Site
- How to Add a Favicon to Your WordPress Website
- How to Fix the WordPress HTTP Error (Uploading Images to Media Library)
- How to Fix TERR_SSL_VERSION_OR_CIPHER_MISMATCH Error?
- Seven Most Common WordPress Errors
- How to Fix the WordPress Updating Failed and Publishing Failed Errors