Fix Missing PHP MySQL Extension in WordPress

missing PHP mysql extension

Have you encountered the error: “Your PHP installation appears to be missing the MySQL extension required by WordPress”? You’re not alone.

PHP missing MySQL extension

Setting up WordPress is generally straightforward, but occasionally, annoying errors can pop up. These issues might seem simple, yet figuring out what went wrong can be confusing.

This is particularly challenging if you’re unfamiliar with technical terms like PHP, MySQL, or other WordPress-related technologies.

One common issue involves MySQL, the database system WordPress uses. This error might appear in several ways:

  • Your PHP installation appears to be missing the MySQL extension required by WordPress.
  • You are missing a MySQL extension.
  • PHP missing SQL extension.
  • WordPress cannot connect to its MySQL database.

Essentially, this error points to a disconnect between PHP and MySQL.

What Exactly Does this Error Mean, and How Can You Fix it?

Don’t worry if you’re not tech-savvy. This blog post will guide you through a quick fix in less than five minutes. We’ve simplified every step, so no programming knowledge is needed. Let’s make it as straightforward as possible for you.

Is your Website Showing a MySQL Extension Error? An Outdated PHP Version could be the Culprit:

Significant changes have affected the MySQL extension since the release of PHP 5.6. If you’re running this version or an older one. It’s possible that the MySQL extension was set up incorrectly or installed improperly.

How to Check Your PHP Version

Start by checking the PHP version your website is running, as conflicts between WordPress and outdated PHP versions often cause the PHP missing MySQL extension error.

Here’s how to check it:

  1. Navigate to the Tools » Site Health section in your WordPress dashboard.
WordPress Site Health Info
  1. Click on the ‘Info’ tab. Scroll down to the ‘Server’ section and expand it to view your server information, including the PHP version.
WordPress Site Health Info PHP Version

If the PHP version listed begins with seven or lower, you’ll need to update it. Upgrading to PHP 8.0 or a newer version not only resolves this error by ensuring compatibility with the latest WordPress but also enhances your site’s security and performance by addressing potential vulnerabilities and bugs.

Mismatch Between WordPress and PHP Versions

Running an old version of WordPress with a newer PHP can lead to problems. WordPress updates regularly, and keeping up with these updates is crucial for security and avoiding technical glitches.

If your website is hosted on a managed platform, they typically handle these updates for you, ensuring your site stays updated and secured.

How to Update WordPress to the Latest Version

To check your WordPress version, go to Dashboard » Updates in your admin panel. Here, you can find the ‘Current version’ listed.

WordPress Available Updates

If your version is 4.9 or older, it’s a good idea to update. This could resolve the missing MySQL extension error. WordPress makes this easy with its built-in update manager, allowing you to upgrade to the latest version with just one click.

Ensure the MySQL Extension is Installed

After updating both PHP and WordPress, if you still encounter the ‘PHP missing MySQL extension’ error, check if the MySQL extension is installed correctly.

Navigate to your WordPress dashboard’s Tools » Site Health page, and switch to the ‘Info’ tab. From there, go to the ‘Database’ section and expand it to check if ‘mysqli’ or ‘mysql’ is listed under extensions.

WordPress Site Health Info Extension

If the extension isn’t installed, contact your WordPress hosting provider’s support team for installation assistance.

Alternative

If the MySQL extension is installed but issues persist, it might be improperly configured.

Common problems include:

  • Incorrect format of the php.ini file.
  • The file paths or location of the php.ini file are wrong.

The php.ini file is crucial as it sets various PHP settings, like your site’s memory limit when PHP starts. Using a php.ini file formatted for a different operating system (like using a Linux-formatted file on a Windows server) can cause issues.

FIRST THINGS: Take a backup of your website before initiating any modifications. Try WP Staging!

Warning: Before deleting, ensure that you download a backup php.ini file for safety.

To resolve this, locate the php.ini file in the /public_html folder of your WordPress hosting. Right-click on the file and select ‘Delete’. Once the file is deleted, restart your website to check if the error is resolved.

Delete php.ini file via cPanel

Check Your PHP Configuration

If you’re still facing the ‘PHP missing MySQL extension’ error, another solution is to verify your PHP settings.

Sometimes, errors can occur if you upload the wrong php.ini file or use an incorrect file path. This file is crucial as it dictates how your site operates.

Common mistakes happen when using a php.ini file intended for a different operating system. For example, a file designed for Windows might be mistakenly used on a Linux server.

First, use FTP/SFTP or SSH to connect to your website. In the main directory (also known as the “root” directory), create a new file named phpinfo.php. Inside this file, insert the following code:

PHP
<?php
phpinfo();
?>

Open your web browser and go to yourdomain.com/phpinfo.php (replace ‘yourdomain’ with your actual domain name). This will show you a page with details about your PHP installation.

Info php.ini file

Once you view the PHP details. This will help you locate the php.ini file.

To make any changes, use an FTP client to navigate the specified file path. It’s wise to back it up before deleting the php.ini file to fix the ‘PHP missing MySQL extension’ error. Download a copy to your computer. This backup ensures you can restore the original settings if needed.

Conclusion

Resolving WordPress issues is generally straightforward, but sometimes, it may require trying several solutions to fix a particular problem. This is often the case with complex issues involving WordPress’s core technologies like PHP and MySQL.

Keeping your PHP and WordPress versions up-to-date can help avoid many similar issues.