WordPress GuideErrors → Fix Missing MySQL

How to fix missing MySQL extension error in WordPress

Seeing the “Your PHP installation appears to be missing the MySQL extension” error on your WordPress site? It usually pops up after switching servers, changing PHP versions, or doing a migration—and it stops your site cold. 

Let’s walk through how to fix it and get your WordPress site back online.

What is the “Missing MySQL Extension” error?

This error means WordPress can’t communicate with your MySQL database because the required PHP extension isn’t available. The specific message often looks like:

WordPress hasn’t used the old mysql extension for years. Instead, it uses newer alternatives like mysqli or PDO_MySQL. But if your server or hosting environment is misconfigured—or if PHP is missing necessary modules—you’ll still run into this error.

Why this error happens in WordPress

Common causes include:

Here’s how PHP versions compare in terms of MySQL extension support:

How to check your PHP configuration

Before making changes, confirm your current setup:

You can also check via command line with:

php -v
php -m | grep mysql

Fix 1: Install or enable the MySQL extension

For cPanel or shared hosting

Most shared hosts let you manage PHP extensions from the control panel. Here’s how:

This ensures the right extensions are compiled into PHP. You may need to switch to an alternate PHP version where these are available.

For VPS or dedicated servers

If you’re managing your own server, you’ll need to install PHP modules manually. For example:

After installing, restart Apache or PHP-FPM:

sudo systemctl restart apache2
# or
sudo systemctl restart php-fpm

This will load the extensions into the PHP environment.

For Docker or custom stacks

If you’re running WordPress inside a container or custom LAMP/LEMP setup, make sure your Dockerfile or provisioning script includes the PHP MySQL modules. Rebuild your image and verify the extension is installed with:

php -m | grep mysql

Fix 2: Downgrade or upgrade PHP

Sometimes the PHP version running on your server isn’t compatible with the plugins or themes you’re using—or it’s missing required extensions.

Stick with PHP versions that balance performance with compatibility. WordPress core works well with PHP 7.4 and PHP 8.1+.

Fix 3: Update WordPress and plugins

Some plugins and older WordPress installs may still expect the deprecated mysql extension. Updating removes that dependency.

If you can’t access the dashboard:

wp core update
wp plugin update –all

Using WP-CLI lets you update the site even when the admin is down.

Fix 4: Check php.ini and .htaccess settings

In php.ini:

The php.ini file controls which extensions PHP loads. Make sure it includes these lines:

extension=mysqli
extension=pdo_mysql

If the lines are missing or commented out (with a semicolon), PHP won’t load the extensions. Uncomment and restart your web server.

In .htaccess:

Check for lines that set the wrong PHP version or interfere with module loading. If your host uses .htaccess to control PHP settings, it could be overriding your chosen version or module path.

Fix 5: Use phpinfo to verify everything

Once you’ve made changes, confirm they worked:

This helps ensure your fixes were applied correctly. Delete the file afterward to avoid exposing sensitive server info.

Fix 6: Reinstall PHP and extensions

If you’ve installed conflicting packages or your PHP environment is corrupted, a clean reinstall might be required.

This is a last resort, but often the cleanest fix if nothing else works.

Fix 7: Contact your hosting provider

If you’re using shared hosting or managed hosting for WordPress, you might not have access to these settings. In that case:

Preventing this error in the future

There are steps you can take to avoid this happening again:

Additional resources

Diagnosing WordPress errors on your site →

Even more common errors, how to troubleshoot them, and how to solve them

WordPress Multisite domain mapping →

A step-by-step guide to setup domain mapping

What is managed WordPress hosting? →

What it means, what it includes, and how to decide if it’s right for you