What Is the Missing MySQL Extension Error?
The error message "Your PHP installation appears to be missing the MySQL extension which is required by WordPress" indicates that PHP cannot find the necessary components to communicate with your MySQL database. WordPress stores all its content--posts, pages, comments, settings, and user data--in a MySQL database. Without the MySQL extension, PHP cannot read from or write to this database, which means WordPress cannot function at all.
This error is fundamentally about the connection between PHP and MySQL. PHP provides several ways to connect to MySQL databases, and WordPress has evolved over time to use newer methods as older ones became deprecated.
The Three MySQL Extensions
- mysql extension: The original extension, now completely removed from PHP
- mysqli extension: The "MySQL Improved" extension, a modern replacement
- pdo_mysql extension: The PHP Data Objects extension, another modern approach
Modern versions of PHP only include mysqli and pdo_mysql. The old mysql extension was deprecated in PHP 5.5 and completely removed in PHP 7.0, as noted in the official PHP documentation.
Common Causes of the Error
1. Outdated WordPress with Modern PHP
The most common cause is running an outdated version of WordPress with a modern version of PHP. When PHP 7.0 was released, it removed the old mysql extension entirely. Any code that tried to use mysql_connect() or related functions would immediately fail.
Modern WordPress (version 3.9 and higher) uses mysqli instead of the deprecated mysql extension. If you're running an older WordPress version, this could be the source of your problem.
2. Missing MySQL Extension Installation
Even with older PHP versions, the MySQL extension might not be installed. This commonly occurs in:
- Fresh server installations where minimal PHP packages were installed
- Linux distributions that split PHP extensions into separate packages
- Custom PHP compilations where MySQL extension wasn't included
3. PHP Configuration Issues
Even when installed, the extension won't load if:
- The extension directive in php.ini is commented out or missing
- The extension path is incorrect
- Multiple php.ini files exist and you're editing the wrong one
- PHP is loading a different php.ini than expected
4. Migration and Server Changes
The error frequently appears after migrating a WordPress site to a new server or hosting environment. Different hosting providers configure their PHP installations differently, and what worked on your old host may not work on the new one. Common scenarios include moving from shared hosting to a VPS, switching operating systems, or upgrading PHP versions during migration. When planning site migrations, consider reviewing our guide on redirects for WordPress to maintain SEO rankings during transitions.
Diagnosing the Error
Method 1: Using phpinfo()
Create a file named phpinfo.php in your WordPress root directory:
<?php
phpinfo();
?>
Navigate to yourdomain.com/phpinfo.php to see your PHP configuration. Look for:
- PHP Version: Check if you're running PHP 7.0 or higher
- Loaded Configuration File: Which php.ini PHP is actually using
- mysqli section: Indicates if the mysqli extension is loaded
Delete this file after diagnosis for security.
Method 2: WordPress Site Health
Navigate to Tools → Site Health → Info tab. Under the Database section, expand to see:
- Extension: Which MySQL extension is in use (should show mysqli)
- Server version: Your MySQL server version
- Client API version: The MySQL client library version
Method 3: Command Line (Server Access)
# Check PHP version
php -v
# List loaded modules
php -m | grep -i mysql
# Find php.ini path
php -i | grep "Loaded Configuration File"
These diagnostic methods help you quickly identify whether the issue stems from an outdated WordPress installation, missing MySQL extensions, or PHP configuration problems. As documented by WPBeginner's troubleshooting guide, the Site Health tool provides a WordPress-native way to diagnose database connectivity issues without creating files on your server.
Step-by-Step Solutions
Solution 1: Update WordPress
If your WordPress version is 3.9 or lower, updating to the latest version will likely resolve the issue:
- Navigate to Dashboard → Updates
- Click "Update Now"
- Verify your site works after the update
If you can't access your admin, update manually via FTP:
- Download latest WordPress from wordpress.org
- Extract and delete wp-content folder and wp-config-sample.php
- Upload remaining files, overwriting existing ones
- Navigate to yoursite.com/wp-admin/upgrade.php
Solution 2: Update Your PHP Version
cPanel Users:
- Go to MultiPHP Manager or PHP Version
- Select your domain
- Choose PHP 8.0 or 8.1
Ubuntu/Debian:
sudo apt update
sudo apt install php8.1 php8.1-mysql
sudo systemctl restart apache2
Solution 3: Install the MySQL Extension
Ubuntu/Debian with PHP 8.x:
sudo apt install php8.1-mysql
sudo systemctl restart apache2
CentOS/RHEL:
sudo dnf install php-mysql
sudo systemctl restart httpd
Solution 4: Configure PHP to Load the Extension
Edit your php.ini and ensure these lines are present (without semicolons):
extension=mysqli
extension=pdo_mysql
Restart your web server after making changes.
Solution 5: Contact Your Hosting Provider
If you're on shared hosting without server access, contact support and provide:
- The exact error message
- Steps to reproduce
- Recent changes made
- Your PHP and WordPress versions
As Hostinger's tutorial explains, most hosting providers can quickly enable the necessary PHP extensions or update your PHP version through their control panel.
Prevention Strategies
Keep Software Updated
The single most effective way to prevent this error is to keep your software current:
- WordPress: Enable automatic updates or check weekly
- PHP: Stay on supported versions (8.0 and 8.1)
- Plugins: Keep updated and remove unused ones
- Themes: Keep your active theme updated
Regular updates ensure compatibility between your WordPress installation and modern PHP versions. This proactive approach prevents most extension-related errors and keeps your site secure. For sites with complex configurations, consider our professional web development services that include ongoing maintenance and monitoring.
Use Managed WordPress Hosting
Managed WordPress hosting providers handle server configuration, including PHP extensions. They ensure necessary extensions are always available and PHP versions stay current. This eliminates the burden of server maintenance while improving reliability and security.
Test Before Major Changes
Before updating PHP versions, test in a staging environment. Most quality hosts offer one-click staging environments to test updates safely without affecting your live site. Understanding your site's responsive design requirements can also help ensure your site remains functional across all devices during major updates.
Regular Backups
Always backup your site before making significant changes. This allows you to restore quickly if something goes wrong during updates. Our web development services include ongoing maintenance packages that handle updates, backups, and monitoring for you.
Frequently Asked Questions
Sources
This guide was compiled using information from the following authoritative sources:
- Kinsta: How to Fix WordPress Missing MySQL Extension Error - Comprehensive guide covering PHP version checking, WordPress updates, extension installation, and configuration troubleshooting
- Hostinger: How to Fix Missing MySQL Extension Error in WordPress - 4-step solution with detailed commands for different hosting environments
- WPBeginner: How to Fix PHP Missing MySQL Extension Error - Site Health method for diagnosis with visual screenshots
- PHP.net: MySQL Extension Documentation - Official PHP documentation on MySQL extension deprecation