WordPress your php installation appears missing mysql extension

5 reasons for error “Your PHP installation appears to be missing the MySQL extension” and how to fix it

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.

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.

Look for the line called “Loaded Configuration File”. The file path noted there is the actual location to the PHP configuration file.

Читайте также:  Сложный генератор пароля php

extension_dir “. It should either be commented, or it should have the correct path to PHP extensions. It should never be left blank.

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

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.

Источник

How to Fix «Your PHP installation appears to be missing the MySQL extension which is required by WordPress»

WordPress is a stable platform. But one of the most common errors is “Your PHP installation appears to be missing the MySQL extension which is required by WordPress.” This happens when your site’s PHP code is not compatible with the PHP version the site is running on.

In this guide, we will resolve the PHP error related to the missing MySQL extension in WordPress.

Your PHP installation appears to be missing the MySQL extension which is required by WordPress tutorial for fixing

  • Access to the server that hosts the WordPress installation (local or SSH)
  • A user account with sudo privileges
  • Access to a command-line/terminal window (optional)
  • A package manager (like yum or apt)

Update WordPress

Updating WordPress to fix php error

Several isssues can cause the WordPress error missing mysql extension. You can resolve many of them by running an update in the WordPress admin.

  1. Log into the wp-admin page of your website, for example, https://examplesite.com/wp-admin/
  2. Click the Updates link in the upper-left corner. The page displays available updates.
  3. Click the Update Now button.
Читайте также:  Sdo nastobr com view doc html mode default

If your installation is up-to-date, WordPress offers an option to reinstall the current version.

WordPress is designed to disable plugins before updating. You can also manually disable any plugins first. Make sure you always update your WordPress installation before updating any plugins.

Check PHP Version on your Server

Log in to the server that hosts your WordPress site, either locally or via SSH. Check the PHP version with the command:

The system displays the version of the installed PHP software as shown below.

ubuntu terminal php -v command showing the installed PHP version

You can also browse the /public_html directory where your WordPress content is stored. Create a new file named info.php, then open it in an editor.

Enter the following line in the file:

Save the file and exit. Now you can load the file in a web browser, and the page will display a long list of all the details.

Check PHP MySQL Extension is Installed

Look through the info.php file we created in the previous section. Under the MySQL Support, find the Client API version cell check the PHP version.

Checking the PHP version in the MySQL support section in the info.php file

Tip: Use Ctrl+F and type MySQL Support to find this section instead of scrolling through the file.

If the Client API Version field is blank, you may be missing MySQL extensions for PHP. Enter the following commands to install them:

sudo apt-get install php5-mysqlnd

Red Hat/CentOS:

sudo yum install php-mysql

Restart the server to apply the changes.

Note: If you are running PHP7.x, replace the commands accordingly.

Check PHP Extension Configuration

If you’ve run any updates or migrated your website, there may be a mismatch in the PHP configuration in the extension_dir where WordPress looks for PHP data. On your PHP info webpage, find the Loaded Configuration File entry with the path to the php.ini file. The line may look something like this:

/opt/imh/imh-php56/root/usr/lib/php/php.ini

This is the location where your server stores PHP configuration.

Next, find the extension_dir entry in the info.php file you loaded in the browser. The line should be commented or contain a valid path to PHP extensions :

/opt/php56/lib/php/extensions/no-debug-non-zts-20131226

If it’s blank, edit the php.ini file:

sudo nano /opt/imh/imh-php56/root/usr/lib/php/php.ini

Scroll down to the extension_dir setting, and either update it to match your actual extension directory, or comment it out. Once you finish, save and exit, then restart your web server.

Читайте также:  Html title more lines

Tip: To mark a line as a comment, start the line with a semicolon ;

Wrong Filename or Path for MySQL.so or MySQL.dll

If you’re using a customized php.ini file, it does not always get updated when you migrate or upgrade your installation. In this case, you need to edit the php.ini file. Use a coding text editor and add the path to the file, for example:

sudo nano /opt/imh/imh-php56/root/usr/lib/php/php.ini

Find and comment the following lines:

; extension_dir=/path/to/extensions/

Save the file and exit, then restart your server and test.

Missing php-mysqlnd-ms Packages (Ubuntu)

Recent versions of Ubuntu operating systems use native MySQL drivers instead of the old PHP libraries. In this case, when the php5-mysqlnd-ms package is missing, the error Your PHP installation appears to be missing the MySQL extension which is required by WordPress may appear.

Install the package by using the following command:

sudo apt-get install php5-mysqlnd-ms

Check for Other PHP Customizations

If you’ve tried all these steps and you still get the “Your PHP installation appears to be missing the MySQL extension” error, you can look at the customized configuration files.

Open your .htaccess file with a full path of your website:

sudo nano path_to_your_website/public_html/.htaccess

Go through and check the version of PHP that’s referenced. It must be the same version of PHP that you checked previously in your info.php file.

If everything looks good in .htaccess, do the same thing for your php.ini file. Again, you’re looking for references to a different PHP version than your info.php file showed.

Change the referenced version or remove that section from the file. Save the changes to the file, exit, and then restart your server.

Note: If you are using customized .htaccess and php.ini files, test your WordPress installation with default versions of these files. You can rename them .htaccess.bak and php.ini.bak to disable them. Then, either copy your backup default versions or download fresh ones.

This tutorial listed several options to fix the error “Your PHP installation appears to be missing the MySQL extension.” Typically, loading the missing MySQL extension for PHP resolves the issue.

Источник

Оцените статью