◦ Comprehensive security
◦ 24/7 support
WordPress Guide → Errors → 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:
Your PHP installation appears to be missing the MySQL extension which is required by WordPress.
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:
- PHP is too new (and lacks backward compatibility)
- PHP is too old (and lacks required modules)
- mysqli or pdo_mysql extensions are missing
- The server stack wasn’t fully configured after a migration
- Incorrect php.ini or .htaccess settings
Here’s how PHP versions compare in terms of MySQL extension support:
| PHP Version | Supports mysql | Supports mysqli | Supports PDO_MySQL |
|---|---|---|---|
| 5.6 | Yes | Yes | Yes |
| 7.0–7.3 | No | Yes | Yes |
| 7.4 | No | Yes | Yes |
| 8.0+ | No | Yes | Yes |
How to check your PHP configuration
Before making changes, confirm your current setup:
- Create a phpinfo.php file with this code:
<?php phpinfo(); ?> - Upload it to your site’s root directory and open it in your browser
- Look for:
- PHP version
- Loaded Configuration File path
- Active extensions list (look for mysqli, pdo_mysql)
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:
- Log into cPanel
- Open Select PHP Version or PHP Extensions under the Software section
- Make sure mysqli and pdo_mysql are checked
- Click Save or Apply
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:
- On Ubuntu/Debian:
sudo apt install php-mysql - On CentOS/RHEL:
sudo yum install php-mysqlnd
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.
- If your host upgraded PHP automatically (e.g., to 8.2), it may have removed old modules. Try switching to PHP 7.4 or 8.1 via your control panel.
- If you’re on VPS, you can install an alternate version with a tool like update-alternatives
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.
- Log in to WordPress admin (if possible)
- Go to Dashboard → Updates and install core, plugin, and theme updates
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:
- Load your phpinfo.php file again
- Scroll down to see if mysqli and pdo_mysql are listed under loaded extensions
- Confirm the PHP version is what you expect
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.
- Back up everything (WordPress files, database, PHP configs)
- Remove PHP:
- sudo apt purge php*
- Reinstall PHP and necessary extensions:
- sudo apt install php php-mysql php-cli php-fpm
- Restart your web server
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:
- Open a support ticket
- Share the full error message
- Include your current PHP version and any steps you’ve taken
Preventing this error in the future
There are steps you can take to avoid this happening again:
- Always test PHP upgrades in a staging environment
- Keep WordPress and plugins up-to-date
- Use a host that supports full PHP configuration
- Monitor your site for errors using tools like UptimeRobot or SiteAlert (formerly WP Health)
Next steps for fixing missing MySQL extension in WordPress
The “missing MySQL extension” error is usually a PHP misconfiguration. Once you confirm your PHP version and ensure the right extensions are enabled, your WordPress site should be back up in minutes.
Start with the easiest fix—enabling mysqli in your PHP settings. If you’re on a VPS, you may need to install or reinstall PHP packages yourself. Shared hosting users should reach out to their provider for support.
Ready to upgrade your WordPress experience? Professional hosting improves speeds, security, and reliability for a website and a brand that people find engaging and trustworthy.
Don’t want to deal with server management and maintenance? Our fully managed hosting for WordPress is the best in the industry. Our team are not only server IT experts, but WordPress hosting experts as well. Your server couldn’t be in better hands.
Click through below to explore all of our hosting for WordPress options, or chat with a WordPress expert right now to get answers and advice.
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