What is the WordPress MySQL extension error?
A MySQL extension error is an error message that indicates that the PHP installation on your server is missing the MySQL extension needed to connect WordPress to your MySQL database. In other words, your PHP version is incompatible with the WordPress software.
While working on your website, you can get the error message "Your PHP installation appears to be missing the MySQL extension which WordPress requires."
The error message often appears when attempting to install or update WordPress. It can be confusing for those experiencing it for the first time, as it suggested that WordPress cannot establish a connection to the MySQL database.
What Causes the “Your PHP Installation Appears to Be Missing the MySQL Extension Which Is Required by WordPress.” Error
The WordPress MySQL extension error occurs when the PHP on your server is unable to establish a connection between your WordPress site and the MySQL database. Consequently, instead of accessing the database, an error message is displayed.
There are several possible causes for this error. Let's see below.
- You are using an older version of WordPress.
- Plugins need to be updated.
- MySQL extension not installed.
- PHP extension is not configured correctly.
The error "Your PHP installation does not appear to have the MySQL extension required by WordPress" usually occurs on new WordPress installations. However, it can also occur if you recently migrated your website, changed your server configuration, or changed your operating system to something that doesn't include the MySQL extension by default, like Linux.
Solution
Below are the possible solutions of the MySQL extension error.
Solution 1. Check what PHP version you’re using
Before you may diagnose what's inflicting the MySQL extension error, you need to recognize which model of PHP your WordPress web website online is walking. You can achieve this in ways.
If you are capable of log in for your WordPress dashboard, you may look at which model of PHP your website online is walking properly for your dashboard.
- Login into the WordPress Admin site
- Go to the left side of the screen and click on the Tools options. After then, click on the Site Health option.
- Under Site Health Status, WordPress will tell you which version of PHP you’re running and whether it should be updated.
If you can't log into your WordPress dashboard, you'll need to use an FTP client to access your website. This process is more complicated but still relatively quick and easy.
- Login into the hosting account through an FTP client such as FileZilla.
- Go to the public_html folder. After then, select the root directory of your website. If your website is the primary domain of the hosting account, then the root directory of your website is /home/cpanel_username/public_html/
If you have added the website as an addon domain, then the root directory of your website is /home/cpanel_username/public_html/websitename/. - Create a file with the name phpinfo.php and enter the following code.
- After then, load that file in the browser. To do this, append /phpinfo.php to your website's URL.
mywebsite.com/phpinfo.php. - Once loaded, the web page will list all PHP settings currently in use on your site, including the current version. The PHP version will be displayed at the top.
- If the PHP version starts with "7.4", you probably need to update your WordPress software. To update the WordPress application, you can go with solution 2 to update WordPress.
- On the other hand, if you are still using PHP 5.x, you may be missing the MySQL extension. In that case, you need to go with solution 4 to verify that the MySQL extension is installed.
Solution 2. Update WordPress
If you're using PHP 7 or higher with an older version of WordPress, you may see a MySQL extension error. This is because the MySQL extension that older versions of WordPress were looking for has been deprecated in PHP 7.0.
Newer versions of WordPress use various extensions, such as the PDO_MySQL and MySQLi extensions, so the error message does not appear. For this reason, check if an updated version of WordPress is available.
If you are still logged into your WordPress dashboard, you can check for updates directly from your dashboard.
- Click on the Dashboard. After then, click on the Updates option.
- If you see the message “An updated version of WordPress is available,” click Update.
If you can't log into your WordPress dashboard, you'll need to use an FTP client to update your software.
- Download the latest WordPress zip file from the wordPress official site in the local system.
- Extract the zip file.
- Log into your hosting account through an FTP client such as FileZilla.
- Go to the wp-content folder.
- Right-click on the plugins folder and rename it “plugins.hold.” This will quickly deactivate your plugins.
- Delete the wp-includes and wp-admin folders.
- Upload the new wp-includes and wp-admin folders from the .zip file you extracted earlier.
- Upload single files from the new wp-content folder to your current wp-content material folder. This will overwrite the prevailing files. Only delete the files on your current wp-content folder, which might be being overwritten via means of new files.
- Upload all new free files for your public_html folder (your WordPress root directory).
- Rename the “plugins.hold” folder back to “plugins.”
You have to be all set. To check it, go to your /wp-admin page. You'll possibly be caused to log back in. Once logged in, you will no longer see a replacement alternative for WordPress on your dashboard.
Solution 3. Update the plugins
Like outdated software, outdated plugins can fit troubles with PHP that set off the MySQL extension error.
If you are logged in on your WordPress dashboard, you can test that all plugins are going for walks with their latest variations on your dashboard.
- Click on the Plugins option.
- If the new version of the plugin is available, you will get a message just below of the plugin that there is a new version of the plugin is available. You will also get the new version details and update now button to update it.
If you cannot log in on your WordPress dashboard, you must replace any old plugins through an FTP client.
- Download the plugin .zip file.
- Extract the .zip file.
- Log into your hosting account through an FTP client such as FileZilla.
- Go to the wp-content folder.
- Click on the plugins folder.
- Delete the folder of the plugin you’re updating.
- Find the extracted plugin folder you just downloaded, right-click it, and press “Upload”.
Solution 4. Verify that the MySQL extension is installed
If you're using an older version of PHP (5.6 and below), the MySQL extension has not yet been deprecated. So if you get a MySQL extension error, it's likely that the extension isn't installed.
To check this, go back to the phpinfo.php file you loaded in your browser in solution 1. Find the line labeled "Client API Library Version". You will see four digits separated by periods.
If you can't find this line, it means that the MySQL extension is not installed. In that case, you can contact your hosting provider and have them install it for you. Alternatively, if you update the version of PHP your website is running on, you no longer need this extension.
Remember to delete the phpinfo.php file when you're done. It contains information about the server; you don't want someone else to see it and use it to access it.
Solution 5. Verify that the PHP extension is configured correctly
Suppose you are using the latest versions of PHP and WordPress. In that case, your PHP extension may not be configured correctly, resulting in the error "Your PHP installation appears to be missing the MySQL extension which WordPress requires".
To check this, go back to the phpinfo.php file you loaded in your browser in Solution 1. Find the line labeled "Loaded Configuration File".
Compare its value with the value in the line labeled extension_dir. If it doesn't match, edit the php.ini file and replace it with the file path listed in the loaded configuration file.
Solution 6: Check Via cPanel
Follow the steps below to check and enable the MySQL extension and PHP Version using cPanel.
Step 1: Log in to your cPanel account provided by your hosting provider.
Step 2: Look for the "Software" or "Software Services" section in cPanel. And find the "Select PHP Version" or "PHP Selector" option.
Step 3: A new page will open, select the “Extention” option showing the PHP versions available on your server. Select the version you're using right now. Scroll down the page, and you see a list of extensions. Look for "mysqli" or "mysql" extension in the list.
If the checkbox next to the extension is unchecked, it means it is currently disabled.
Step 4:Check the box next to the "mysqli" or "mysql" extension to enable it.
Step 5: Click the "Save" or "Apply" button to save the changes.
Conclusion:
If you come across the " your PHP installation appears to be missing the MySQL extension which is required by WordPress." error may be extremely frustrating and look very technical, but don't worry. Above are the steps you can use to solve it.
Our main suggestion for resolving this issue is to confirm that PHP and WordPress are both installed in the most latest versions. By keeping your PHP version up to date and regularly updating your WordPress installation, you can ensure compatibility and resolve this error. This will not only help with resolving the error but also improve the efficiency and functionality of your WordPress website.