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

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

Trying to tướng install WordPress or visit your WordPress site only to tướng encounter an error that says “Your PHP installation appears to tướng be missing the MySQL extension which is required by WordPress.”?

As with any WordPress error message, it can be frustrating to tướng 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 to tướng connect to tướng its MySQL database.

In this article, we’ll go over what that “something” might be and share some tips on how to tướng 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 to tướng 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 to tướng connect your WordPress site to tướng 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 to tướng Fix “Your PHP installation appears to tướng 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 to tướng troubleshoot and fix the issue.

1. Check What Version of PHP You’re Using

The first step to tướng diagnose this issue is to tướng figure out which version of PHP your WordPress site’s server is running. The answer to tướng this question will dictate the next steps that you take.

To kiểm tra this, connect to tướng 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 to tướng connect.

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

Once you’ve connected to tướng 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 to tướng yoursite.com/phpinfo.php, making sure to tướng 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 to tướng the Core section and look for the PHP Version item. Pay attention to tướng the numbers – you should see something lượt thích x.x.x. E.g. 7.2.25 or 5.6.8:

How to tướng kiểm tra WordPress PHP version
How to tướng kiểm tra your WordPress site’s PHP version

If your PHP version starts with a “7”, that usually means that you need to tướng 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 to tướng your site.

Learn more about why it’s important to tướng use modern, supported PHP versions.

2. Update the Vi xử lý 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 to tướng 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 to tướng 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 to tướng 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 to tướng delete it if it’s there).
  • The wp-content folder.

Once you’ve deleted those items, upload the remaining files/folders to tướng your server via FTP. When prompted about duplicate files by your FTP client, tell it to tướng overwrite all files:

How to tướng 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 to tướng update all of your plugins and themes to tướng the latest versions as well. You can follow these guides:

  • How to tướng update WordPress plugins
  • How to tướng update WordPress themes

3. Check to tướng 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 to tướng the phpinfo.php tệp tin that you uploaded to tướng 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 to tướng the Client API library version item:

How to tướng see if WordPress MySQL extension is installed
How to tướng 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 to tướng reach out to tướng your host’s tư vấn staff and ask them to tướng 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 to tướng upgrade your server to tướng PHP 8+ instead of putting time into properly configuring an older version of PHP. You can follow our guide on how to tướng update the PHP version of your WordPress site and how to tướng 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 to tướng find WordPress php.ini tệp tin path
How to tướng find WordPress php.ini tệp tin path

First, we recommend backing up the existing tệp tin by downloading it to tướng 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 to tướng be missing the MySQL extension which is required by WordPress” message is a frustrating error to tướng encounter because it seems sánh technical.

However, with the steps in this article, you should be able to tướng diagnose and fix the issue.

Our recommended solution is to tướng 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 to tướng 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.