List of content you will read in this article:
Today, most companies are relying on WordPress for creating dynamic, efficient, and robust websites. But sometimes the website tends to fail and becomes unavailable to access. Thus making it very frustrating for owners as well as customers to encounter various errors while connecting or accessing a website. One of the most commonly occurring errors is “Your PHP installation appears to be missing the MySQL extension which is required by WordPress.
Well, you do not have to worry as this might be due to some error at the code end of the site or there are some issues that are preventing the website from connecting to the database.
In this article, we will look for a possible fix that helps in troubleshooting and fixing this error. We will learn what this error is about, possible reasons for its occurrences, basic requirements for solving this error, and various steps for fixing this issue.
What do you mean by this error?
This is one of the commonly occurring and dreadful errors that you may face while logging into the WordPress dashboard. There can be various reasons that cause this error to occur. But you need to do some workaround to understand the error and what is causing it.
Generally, it might be possible that the PHP code that helps in running WordPress on the server has some parts missing that cause this error to occur again and again. Sometimes, the PHP version of the server might not be able to read the MySQL extension. It is important for you to get the base of the error and what possible reasons can be behind it making it occur again and again. Once you understand the error, you know how to start troubleshooting those possible reasons for fixing them as soon as possible.
Most possible reasons for this error
As per the name of the error message, it indicates that the error is related to the PHP on your server that has a missing MySQL extension which is mandatory for connecting your WordPress website to the MySQL database. We have mentioned two main reasons that might lead to this error.
- In the case of the older version of WordPress along with the latest and updated PHP version, you can come across this error as PHP 7.0 deprecated the MySQL extension in favour of mySQLi. It means that the PHP 7+ version does not come with the MySQL extension that can be used by WordPress. If you are using the latest WordPress version, it will use the latest PDO_MySQL or MySQLi extension for proper working. But, if you are stuck with the older version of WordPress, you might have to face this error.
- Another reason can be if you are using the PHP older version with incorrect configuration or missing the MySQL extension.
Prerequisites for fixing the error
If you are looking to fix this error, then you do not require many settings and credentials. But if you want to look into the website’s files then you will require the following credentials and access. So make sure you have the right access for fixing this error.
- First, you must know what version of PHP is being used by the WordPress website. If you are working on the latest version of WordPress then you must find it under the WordPress account dashboard. But you have to access the command line to your website.
- In order to make the required code changes, you must be having admin access to the command line and the server. But if you are an owner of the website then you can find the credentials on your hosting account’s dashboard.
- For accessing the files on the server, you should have an SFTP client and basic FTP skills.
- You should also be having a code editor, allowing you to write the required code and upload it to the server.
Having all these thighs beforehand will help you in troubleshooting and fixing any type of WordPress related errors instantly. Else, getting this access may take time and your website will have to face a long downtime impacting the identity of your website among customers and competitors.
How to Fix the Error?
Below are some steps that you can follow for fixing this error effortlessly. But it is only possible if you have the right authorization and access in place.
- Updating the core files of your WordPress.
- Checking for the available version of the PHP.
- Installing or Updating the required MySQL extension.
Method 1. Updating Your WordPress Installation
This step is very simple, you just need to login into your WordPress with the right credentials and access the dashboard. From there, you can go to the Updates screen and make the required core updates as shown below.
From this page, install the new updates. After the completion of the installation process, check for the error again. If there is no error, it means there was something wrong with the core files of WordPress. Make sure you install the WordPress updates more frequently from this error to happen in future. But if you are facing the error again, then you need to move to the next troubleshooting process.
Method 2. Checking the server’s PHP Version
Before making the changes to the core files of WordPress make sure to have a clean backup of the website in case of any failure, you will be able to restore your website. Apart from this, have your credentials ready for accessing the server of your WordPress website.
1. Create a PHP File and access Your Server
Use your credentials for logging into the server of your WordPress website using SSH. then open the command line for checking the version of running PHP. you can use the below command to do so.
The above command will help in displaying the version of the installed PHP as shown below.
After this, you can type the below snippet into your text editor.
<?php phpinfo(); ?>
Remember to save this file named info.php. Then, log into your website server with the help of an SFTP client with the appropriate credentials that you find from your account’s dashboard. Once you log into the server, you will get the below list of files that are related to your website.
If you are running several websites on your server, then you will find multiple folders here on the server. But you can find only one site under the primary public_html or www folder. while other sites are under a directory with the same name as the site in question.
2. Uploading Your info.php File and Checking Your Site
After that, you can start by uploading the newly created info.php file on the website’s server. You can use the drag and drop functionality for transferring the file. Then try running this info.php file within your browser and check for the site’s availability. After running the page, you will get the below diagnostic page.
Here, you can check the configuration details of your PHP and its version. You can check the details as shown below.
If you see that the highlighted number above begins with 7 and updating the WordPress does not resolve the issue. Then it is time that you contact your host that is helping you in hosting your website. As it will require an experienced person to get into more details.
Method 3. Configuring and installing the MySQL Extension
If the above mentioned two methods do not help in fixing the issue and you are still facing the error then you can try checking the MySQL extension. It probably requires configuration setting or most probably installing the new extension.
1. Checking the info.php File
Again, open the info.php file from your browser and this time instead of the PHP version, we will focus on the MySQL section as shown below.
If there is a number present next to the Client API library version field, it indicates that the MySQL version is installed. Otherwise, contact your host. To resolve this, make sure you update the version of PHP frequently or you can ask your host to do so.
2. Checking for the Configured the MySQL Extension
If you can find the number for the MySQL installation, then proceed with checking its extension. There might be some problem with the php.ini file. You can reconfigure this file by removing it from the server and going back to the info.ph file and looking for the Loaded Configuration File field as shown below.
Again use SFTP for logging back to the server and look for the above-highlighted path. You need to move the file using the drag functionality from the server to your local system for backup perspective and then delete the file from the server.
Then reload your website to check if the error still persists. Then check the backend for any possible error. If there is no error then the MySQL extension is not configured properly. If the error is there, then try contacting your host.
Method 4. Checking PHP Extension Configuration
If you have recently updated or migrated your website, then you may find a mismatch in the PHP configuration that is available in the extension_dir. WordPress uses this location for looking for PHP data.
Go to your PHP info webpage for looking at the Loaded Configuration File entry displaying the path to the php.ini file. You will follow a path like this.
It is where your server contains the PHP configuration.
Then, you need to find the details for the variable extension_dir in the info.php file that you have loaded in the browser. Then make sure you have commented a valid path to PHP extensions as below.
If it is blank then you need to edit the php.ini file as below.
sudo nano /opt/imh/imh-php56/root/usr/lib/php/php.ini
Again go back to the extension_dir setting and update it with the new extension and save the changes. After this, you need to restart the webserver.
Method 5. Look for the Filename or Path for MySQL.so or MySQL.dll
If you are working with the customized php.ini file, then you need to make sure that the file gets updated during the migration or updation of the website. For this, you need to make some changes to the php.ini file. For making the required changes, open the coding text editor and add the following path to the file.
sudo nano /opt/imh/imh-php56/root/usr/lib/php/php.ini
Then you need to locate and comment the following lines:
- ; extension=mysql.so
- ; extension_dir=/path/to/extensions/
After making the changes, save the file, and restart your web server. Then make sure you test your website for errors.
Method 6. Check for missing php-mysqlnd-ms Packages (Ubuntu)
The latest versions of the Ubuntu OS uses the native MySQL drivers rather than using the old PHP libraries. If you have a missing php5-mysqlnd-ms package, then you will face this error. It is possible that you might be missing the MySQL extension that is required by WordPress.
You can install the required package by running the following command:
sudo apt-get install php5-mysqlnd-ms
After making the required changes, save the changes, and restart your web server. Then go to the website and reload it to check for the error.
WordPress is most likely used CMS and tends to face some errors while running the website. Such errors may be due to the technical issues and various inappropriate settings available. Well, you do not have to worry about “your php installation appears to be missing the MySQL extension which is required by WordPress” error, as you can fix it by running the above-mentioned workarounds. You just need to have the right credentials to access the server and its command line for running various commands required as a part of fixing the error.
I'm fascinated by the IT world and how the 1's and 0's work. While I venture into the world of Technology, I try to share what I know in the simplest way with you. Not a fan of coffee, a travel addict, and a self-accredited 'master chef'.