How to Fix "Your PHP Installation Appears to Be Missing the MySQL Extension Which Is Required by WordPress" Error

  • 1,000
  • Tác giả: admin
  • Ngày đăng:
  • Lượt xem: 1
  • Tình trạng: Còn hàng

Trying đồ sộ install WordPress or visit your WordPress site only đồ sộ encounter an error that says “Your PHP installation appears đồ sộ be missing the MySQL extension which is required by WordPress.”?

As with any WordPress error message, it can be frustrating đồ sộ encounter a problem that prevents you from using/accessing your WordPress site.

However, don’t despair!

Generally, this error means that something is going wrong with the code on your site and something is preventing WordPress from being able đồ sộ connect đồ sộ its MySQL database.

In this article, we’ll go over what that “something” might be and share some tips on how đồ sộ troubleshoot and fix this error message.

What Causes the WordPress Missing MySQL Extension Error?

As we mentioned in the introduction, the error message “Your PHP installation appears đồ sộ be missing the MySQL extension which is required by WordPress” steps from some issue with the code/scripts on your server.

Specifically, this error means that the PHP on your server doesn’t have the necessary extension đồ sộ connect your WordPress site đồ sộ its MySQL database.

There are two main reasons why this might be the case:

1. You’re Using an Outdated Version of WordPress with PHP 7+

If you’re using a very old version of WordPress with a modern version of PHP, you might encounter this error because PHP 7.0 deprecated the MySQL extension in favor of MySQLi. That is, PHP 7+ no longer includes the MySQL extension that WordPress is looking for.

Modern versions of WordPress will instead use the newer PDO_MySQL or MySQLi extensions. However, older versions of WordPress (below version 3.9) might cause this problem.

2. You’re Using PHP 5.6 or Lower but the Extension Is Missing or Improperly Configured

The other likely cause is that you are using PHP 5.6 (before the MySQL extension was deprecated), but the extension is either missing or improperly configured.

How đồ sộ Fix “Your PHP installation appears đồ sộ be missing the MySQL extension which is required by WordPress”

Now that you know what’s going on, let’s go over some tips for how đồ sộ troubleshoot and fix the issue.

1. Check What Version of PHP You’re Using

The first step đồ sộ diagnose this issue is đồ sộ figure out which version of PHP your WordPress site’s server is running. The answer đồ sộ this question will dictate the next steps that you take.

To kiểm tra this, connect đồ sộ your WordPress site’s server using FTP. You can get your FTP credentials from your trang web host and you’ll also need an FTP client đồ sộ connect.

If your host is using cPanel, you can use the cPanel File Manager tool.

Once you’ve connected đồ sộ your server, create a new tệp tin called phpinfo.php in the root directory of your WordPress site. This should be the same thư mục that contains your wp-config.php file.

Then, edit the tệp tin and add the following code snippet:

phpinfo();
?>

Once you save the tệp tin (and re-upload the saved version if needed), navigate đồ sộ yoursite.com/phpinfo.php, making sure đồ sộ replace yoursite.com with your actual tên miền name.

You should see a screen that displays a lot of different information about the PHP configuration on your server. Scroll down đồ sộ the Core section and look for the PHP Version item. Pay attention đồ sộ the numbers – you should see something lượt thích x.x.x. E.g. 7.2.25 or 5.6.8:

How đồ sộ kiểm tra WordPress PHP version
How đồ sộ kiểm tra your WordPress site’s PHP version

If your PHP version starts with a “7”, that usually means that you need đồ sộ update the WordPress software. On the other hand, if you’re still using PHP 5.X, you might be missing the MySQL extension.

Note – at Kinsta, we strongly recommend using the latest version of PHP. In fact, we don’t tư vấn versions below PHP 8.0. These older versions have slower performance and, because they no longer receive security updates, could pose a security risk đồ sộ your site.

Learn more about why it’s important đồ sộ use modern, supported PHP versions.

2. Update the Chip Core WordPress Software

If your server is using PHP 7+, the most likely cause of this error is that you’re running an old version of WordPress. If you’re using WordPress version 3.9 or lower, that can trigger this error.

Therefore, the fix is đồ sộ update your WordPress software, which will also come with lots of other features, security, and performance improvements.

To manually upgrade your WordPress version, first, make sure you have a backed up version of your site. Then, go đồ sộ WordPress.org and tải về the most recent copy of the WordPress software.

Once you’ve downloaded it, extract the zip tệp tin đồ sộ your computer. Then, open the thư mục that contains all of the WordPress files and delete the following items:

  • The wp-config-sample.php file.
  • The wp-config.php file (you might not see this tệp tin – just make sure đồ sộ delete it if it’s there).
  • The wp-content folder.

Once you’ve deleted those items, upload the remaining files/folders đồ sộ your server via FTP. When prompted about duplicate files by your FTP client, tell it đồ sộ overwrite all files:

How đồ sộ reinstall WordPress software
Reinstall WordPress by overwriting the existing files

Once the tệp tin uploads finish, your WordPress site should be running the most recent version and your issue should be fixed.

As a follow-up step, you should also make sure đồ sộ update all of your plugins and themes đồ sộ the latest versions as well. You can follow these guides:

  • How đồ sộ update WordPress plugins
  • How đồ sộ update WordPress themes

3. Check đồ sộ See If the MySQL Extension Is Installed

If your server is still using PHP 5.6 or lower, your server might be missing the MySQL extension that WordPress requires.

To kiểm tra if this is the case, go back đồ sộ the phpinfo.php tệp tin that you uploaded đồ sộ your server in Step #1.

Look for a section named either mysql or mysqli.

If the MySQL extension is installed, you should see a version number next đồ sộ the Client API library version item:

How đồ sộ see if WordPress MySQL extension is installed
How đồ sộ see if WordPress MySQL extension is installed

If you can’t find this information, that means the MySQL extension is not installed. The best solution is usually đồ sộ reach out đồ sộ your host’s tư vấn staff and ask them đồ sộ install it for you.

Note – again, we highly recommend not to use PHP versions below 8.0 because they no longer receive security updates and don’t perform as well as newer versions.

Unless you absolutely must continue using PHP 7.4 or lower, a much better solution is đồ sộ upgrade your server đồ sộ PHP 8+ instead of putting time into properly configuring an older version of PHP. You can follow our guide on how đồ sộ update the PHP version of your WordPress site and how đồ sộ install PHP on any server.

4. Make Sure PHP Extension Is Configured Properly

If you’re using PHP 5.6 or lower and the extension is installed, the issue might be that it’s not configured properly. Two common issues are:

  • Uploading a php.ini tệp tin that’s intended for Windows servers when you’re using a Linux server
  • Incorrect tệp tin paths.

You can find the location of your php.ini tệp tin in the phpinfo.php tệp tin that you created before:

How đồ sộ find WordPress php.ini tệp tin path
How đồ sộ find WordPress php.ini tệp tin path

First, we recommend backing up the existing tệp tin by downloading it đồ sộ your local computer. Then, try deleting the php.ini tệp tin and see if that fixes the problem.

Summary

The “Your PHP installation appears đồ sộ be missing the MySQL extension which is required by WordPress” message is a frustrating error đồ sộ encounter because it seems so sánh technical.

However, with the steps in this article, you should be able đồ sộ diagnose and fix the issue.

Our recommended solution is đồ sộ make sure you’re using the most recent versions of both PHP and WordPress.

If you use PHP 8+ and WordPress 5.0+, you should be able đồ sộ automatically fix this error and get your site working again, while also benefiting from all of the other performance, security, and feature enhancements that come from updating.