How to Fix “Your PHP Installation Appears To Be Missing The MySQL Extension Which Is Required By WordPress” Problem
Have you ever faced the frustrating situation of trying to make technical changes on WordPress, only to be met with an error message that reads, “your PHP installation appears to be missing the MySQL extension which is required by WordPress”? If so, you're not alone. Fortunately, this blog post is here to help you find the solution to this issue.
Why Are You Witnessing this Error?
This error usually occurs due to an issue on the server's end. What happens is that a required extension is missing in the PHP code of your WordPress website, which is needed to connect to the MySQL database and enable your website to function properly.
In other words, the PHP version you are using may not be compatible with the version of WordPress you are running.
But don't worry, this error is manageable. There are three main reasons why this error occurs:
- You may have an outdated version of the MySQL extension. This is usually a problem when you are using PHP 7.0 or higher, as for these versions, the MySQL extension was terminated.
- You could be using an outdated version of WordPress, which may make it hard for the platform to fetch the MySQL extension.
- There might be a misconfiguration between your PHP version and the MySQL extension, creating the error.
How to Fix the Missing MySQL Extension in the PHP Installation Error?
1. Verify the Eligible PHP Version
First and foremost, you need to check if you have a compatible version of PHP installed. The eligible version of PHP for the MySQL extension is 5.6 or lower. In this method, we will guide you through the steps using the CentOS panel. However, you can also use an FTP client like Filezilla to accomplish the task.
- Go to the File Manager tab on your dashboard.
- Head to the public_html folder.
- Add a new folder to the list and name it the phpinfo.php file.
- Edit this file by adding the code,
<?php
phpinfo();
?>
- Now to check the PHP version of your website, head to the address bar and reload your website with the /phpinfo.php at the end of the URL. Like this, yourwebsite.com/phpinfo.php. This will open a webpage.
- Scroll to find the Core tab under which you will find the PHP version of your website. The first number usually indicates the version of PHP.
Another way to check the PHP version is by navigating through the WordPress dashboard. Here is what you need to do;
- Go to Tools and then to Site Health.
- Under the Site Health Info tab, locate Server.
- Here, you can spot the PHP version of your website.
2. Check the Status of the MySQL Extension
If you already have the right version of PHP installed (5.6 or lower), then you need to check if the MySQL extension is enabled. To do this, you must create a file phpinfo.php. If you have already seen this method above, skip the following steps. Otherwise, you can continue here.
- Go to the File Manager tab on your dashboard.
- Head to the public_html folder.
- Add a new folder to the list and name it the phpinfo.php file.
- Edit this file by adding the code,
<?php
phpinfo();
?>
- Now to check the PHP version of your website, head to the address bar and reload your website with the /phpinfo.php at the end of the URL. Like this, yourwebsite.com/phpinfo.php. This will open a webpage.
If you have already followed the above steps, here is what you need to do next;
- Look for the mysql or mysqli or pdo_mysql tab.
- Find the row that says Client API version. Next to it, you will find the version of the MySQL extension.
If, however, you cannot locate this on the webpage, it means that you are missing the MySQL extension. Now, you can try out two solutions, either contact your hosting provider for a quick installation or upgrade the PHP so that the extension becomes redundant.
3. Check the Configuration of the PHP Extension
Often, the installation is right and the version is valid too but due to incorrect file paths, there is a misconfiguration between the two parties. It occurs because the file intended for a Linux server happens to be for a Windows server.
First, you need to create the phpinfo.php file just like we did before. If you have already followed through with these, skip to the next step.
- Go to the File Manager tab on your dashboard.
- Head to the public_html folder.
- Add a new folder to the list and name it the phpinfo.php file.
- Edit this file by adding the code,
<?php
phpinfo();
?>
- Now to check the PHP version of your website, head to the address bar and reload your website with the /phpinfo.php at the end of the URL. Like this, yourwebsite.com/phpinfo.php. This will open a webpage.
Then, locate the Loaded Configuration File. This will tell you all the information you need to know about whether the configuration is valid or not.
If you think this is the problem, create a backup of this file and then delete the existing php.ini file. Reload the website to see if the error is still there.
4. Update the Outdated WordPress Version
An outdated version of any software or program can lead to a haywire of errors. Hence, it is always best to keep your software updated to prevent unnecessary bugs. Similar is the case for this solution to fixing the missing MySQL extension issue. You need to upgrade the WordPress version to avoid the error from occurring.
- Head to WordPress.org and download the latest version.
- Extract the zip file to explore the folder contents.
- Locate the wp-content folder.
- Rename the plugins folder to plugins.hold to disable the plugins for a short amount of time.
- Delete these; wp-config-sample.php file, wp-config.php file, and the wp-content folder.
- Upload the recently downloaded and extracted files through an FTP client like Filezilla. If there is a duplicate error visible, remove it by clicking on the Overwrite option.
- Put the plugins back in action by changing the name from plugins.hold back to plugins.
5. Update the Necessary Plugins
An outdated plugin can also prompt the missing MySQL extension error. You can mitigate this by heading to WordPress and updating all plugins. If that seems like too much work, you can also use an FTP client for updating your plugins.
- Download and extract the plugin.zip file.
- Use an FTP client through a third party or manually use one. You can opt for Filezilla.
- Locate the wp-content folder and then the plugins folder.
- Delete the existing folder of the plugin you wish to update.
- Then, upload the latest version of that plugin. Do this by right-clicking on the extracted plugin folder and clicking on Upload.
Conclusion
All in all, a missing MySQL extension is mainly caused by outdated versions or incorrect file paths. In this blog, we have covered some basic solutions on how to remove this error. Hopefully, these quick fixes will help you out in a matter of minutes. Nonetheless, we do recommend updating PHP to the latest version to prevent such errors from occurring in the first place.
FAQs
Which PHP Version Works Best for WordPress?
The best version of WordPress is obviously the latest one. As of today, that is PHP 8.1. If for some reason, you cannot employ the 8.1 version, then the oldest version we can suggest that you use is PHP 7.4. This advice is for WordPress 5.9 and higher.
Is MySQL Necessary for PHP?
MySQL is a database to manage data profiles, statistics, or infographics. It may be a necessity in some cases but there are other alternatives to MySQL that you can employ.