Support Engineers at Bobcares manage thousands of WordPress sites of web designers, digital marketers, online publishers, web hosts and more.
In these sites, this error usually comes up after a recent migration:
Your PHP installation appears to be missing the MySQL extension which is required by WordPress.
Today we’ll take a look at the top 5 reasons for this error, and how to fix them.
1. PHP’s MySQL extension not installed
PHP’s ability to send SQL commands to MySQL comes from an additional module called MySQL extension. In some default operating system setup, this extension might not be present.
To check if your PHP has MySQL support, put the following code into a file called info.php in your site, and access it from a browser.
<?
phpinfo();
?>
It should show a MySQL section like this:
If not, you may have to install MySQL extensions.
In Ubuntu servers, use the command:
# apt-get install php5-mysqlnd
In RedHat compatible servers, use the command:
# yum install php-mysql
[ Website errors can drive your customers away. Click here to get an experienced server admin to monitor & maintain your server 24/7. ]
2. PHP extension directory mis-configured
In some websites, especially those that were recently migrated, or in a newly setup VPS, the “extension_dir” is sometimes misconfigured.
This directory stores all the PHP libraries, and if not set correctly, PHP cannot execute those functions.
To fix this, first locate which PHP.ini file is being loaded by your website. For this, put the following code into a file called info.php, and access it from a browser.
<?
phpinfo();
?>
Look for the line called “Loaded Configuration File”. The file path noted there is the actual location to the PHP configuration file.
Now, look for the entry called “extension_dir“. It should either be commented, or it should have the correct path to PHP extensions. It should never be left blank.
If you are not sure, just comment the line, and restart the web server.
3. Wrong file name/path for MySQL.so or MySQL.DLL
Some websites have custom configured PHP configuration (php.ini) files. These files will not be automatically updated by system programs during an upgrade or a migration.
We’ve seen typing mistakes and wrong extension directory paths put in the custom configuration files.
If you have a custom configuration file, it is best to comment out the lines that have the following:
; extension=mysql.so
; extension_dir=/path/to/extensions/
[ A single misconfiguration can break your site! Our support engineers perform flawless upgrades and keep your site stable & secure. Click here to know more. ]
4. Missing php-mysqlnd-ms packages in Ubuntu servers
In the later Ubuntu operating systems, MySQL’s native drivers are used instead of the old PHP libraries.
In these systems, if the package php5-mysqlnd-ms is not installed, it can result in this error.
So, to fix it use this command:
# apt-get install php5-mysqlnd-ms
[ Don’t wait till your website goes down. Protect your site with timely upgrades and maintenance. Click here to know more. ]
5. Incorrect PHP config via suPHP_ConfigPath
In servers where suPHP is enabled, custom PHP configuration files are loaded through suPHP_ConfigPath.
These PHP config files sometimes contain conflicting entries on MySQL extensions. This is especially true in the case of shared servers where Multi-PHP option is available (eg. cPanel/WHM and Plesk servers).
So, if suPHP_ConfigPath is defined in .htaccess of virtual host configuration of a website, try commenting it out to see if the error is resolved. If so, then the custom PHP.ini should be reviewed and conflicting entries should be removed.
In short..
“Your PHP installation appears to be missing the MySQL extension which is required by WordPress.” is a common error faced by websites that are recently migrated or PHP upgrade done. Here we’ve seen the top 5 causes for this error, and how to resolve them.
Bobcares helps online businesses of all sizes achieve world-class security and uptime, using tried and tested solutions. If you’d like to know how to make your server more reliable, we’d be happy to talk to you.
Thanks for the help!
/* in my setup, your code
doesn’t work. I had to write
instead.
*/
Hi Ribo,
Which OS and PHP version are you using?
As per PHP documentation (http://php.net/manual/en/configuration.file.php), semicolon (;) should work as a comment marker. # is no longer considered a comment marker.
Got this error. It wound up being the Hosting company at fault.
My PHP version was switched to Version 7. I put it back to V5.6 (I think) and my website came back to life.
(time to upgrade my wordpress as have not done the last few)
Thank you Jim for sharing. 🙂
Thank you, this helped me too.
Jimako,
Good to hear from you 🙂
Thanks a lot! In my case, the 5º (of course :D) solved the problem!
Juliano,
Good to know that 🙂
I was simply reading an article that was written on WordPress. I didn’t finish it and went back a couple of times to keep reading. After turning my computer off for an evening, when I turned it back on this error was written in place of the article. I don’t have WordPress, I was simply reading the article which was there for several days before I received this error message. What’s going on. I don’t have a clue what PHP or MySQL are nor am I trying to write on WordPress. Just a reader of an article. Thanks.
WordPress sites store the content in a database. When the site is unable to connect to the database to retrieve the content, this error is shown.
Unless it is your site, you don’t have anything to worry about. The site owners will get it fixed through their web hosting providers.
If this is indeed your site, it looks like the PHP installation in the server must have been recently upgraded or changed. It may need to be reconfigured. Please contact us by clicking here if you need assistance with your website.
Commented out – extension_dir = ./ – WORKED THANK YOU!!
register_globals = off
allow_url_fopen = off
expose_php = Off
max_input_time = 60
variables_order = “EGPCS”
;extension_dir = ./
upload_tmp_dir = /tmp
precision = 12