Checking PHP Version Compatibility and MySQLi Drivers
This error appears when the mysqli extension is not installed or not enabled in the PHP version your site runs on; WordPress uses this extension to connect to the database. The most common cause is that after the PHP version was changed in the hosting panel, the mysqli box is not checked for the new version. In cPanel, checking the mysqli box on the Extensions tab of the Select PHP Version screen fixes the error in most cases.
- Log in to your hosting panel (cPanel, Plesk or DirectAdmin) and check your PHP version.
- Make sure the PHP version in use is compatible with your current WordPress version; the current requirements are listed at wordpress.org/about/requirements.
- If the site runs a very old WordPress version (before 3.9), the same error appears on PHP 7 and later because the old mysql extension was removed in PHP 7.0; replace the core files with the current version via FTP.
What to Watch Out for When Switching PHP Versions
When switching versions, make sure that not only the main extensions but also the supporting libraries are enabled. Extension selections are stored separately for each PHP version; when you move to a new version, check that the mysqli box is also checked for that version.
- Always take a full site backup before making changes.
- After changing the version, check the Site Health screen.
- Watch whether older plugins conflict with the new PHP version.
| Method | Difficulty | Estimated time | Requirement | When to use it |
|---|---|---|---|---|
| Enable the PHP module | Low | 3 minutes | Hosting panel | First thing to try |
| Install the package via SSH | High | 10 minutes | Root access | VPS or your own server |
| Edit php.ini | Medium | 5 minutes | FTP/File Manager | If you have access to the php.ini file |
| Downgrade/upgrade PHP | Low | 2 minutes | cPanel/Plesk | If the error appeared after a version change |
| Verify the file path | Medium | 7 minutes | Technical know-how | If the extension is enabled but not loading |
Configuring the Extension in the php.ini File
php.ini is the main configuration file that determines which modules PHP loads on the server. If you are getting the WordPress MySQL error, the semicolon (comment marker) in front of the MySQL extension in this file may not have been removed. This causes PHP to ignore the database engine.
- Go to your site’s root directory or the PHP installation directory via FTP or File Manager.
- Open the php.ini file and search for the lines “extension=mysqli” or “extension=php_mysqli.dll”.
- If these lines start with “;” (semicolon), delete it and save the file.
Extension Directory Path Settings
Sometimes PHP cannot find the extension’s physical file even when it is enabled. In that case, make sure the “extension_dir” parameter points to the correct path.
- Check the “extension_dir” path in the phpinfo() output.
- Verify that mysqli.so or php_mysqli.dll exists in that directory.
- If the path is wrong, set the full path manually in the php.ini file.
Installing the Package from the Linux Terminal (VPS/Dedicated)
If you use your own VPS or dedicated server instead of shared hosting, the MySQL extension may never have been installed at the operating system level. On systems like Ubuntu, Debian or CentOS, the MySQL packages are sometimes kept separate when the PHP core is installed. A short series of commands over SSH will fix this for good.
- Connect to your server with root access via SSH.
- On Ubuntu/Debian, run
sudo apt-get install php-mysql. - On CentOS/RHEL, use
sudo yum install php-mysqlnd.
Restarting the Services
After the package is installed, you must restart the web server and the PHP service for the changes to take effect. Otherwise the system will keep using the old configuration.
- If you use Apache, run
sudo systemctl restart apache2. - If you use Nginx and PHP-FPM, run
sudo systemctl restart php8.x-fpm(depending on your version). - Clear the server cache (Varnish, Redis, etc.) and check in your browser that the error is gone.
Source: PHP Manual: Installing mysqli
Related serviceDatabase Optimization ↗Database Settings in wp-config.php
Wrong connection details do not cause this error: if the host name, username or password in your wp-config.php file is wrong, WordPress shows the message “Error establishing a database connection”. If you see that message after enabling the extension, check the settings below; with cloud or remote databases, you may need the host name provided by your provider instead of “localhost”.
- Open the wp-config.php file and find the
DB_HOSTline. - If it says “localhost” and you are getting an error, try changing it to “127.0.0.1”.
- If your database server uses a different port (for example 3307 instead of 3306), specify it as
localhost:3307.
Forcing the Database Driver
WordPress uses the mysqli extension automatically if it is installed. A constant added to the wp-config.php file cannot replace an extension that is missing on the server.
- The line
define( 'WP_USE_EXT_MYSQL', false );at most determines which driver is selected; if mysqli is not installed in PHP, it won’t fix the error, so enable the extension first. - Test that your database username and password are current via the control panel.
- Make sure the user has ALL PRIVILEGES on the database in question.
Module Management in the Hosting Control Panel
Modern hosting panels let users turn modules on and off without touching the php.ini file. The “Select PHP Version” section in cPanel or “PHP Settings” in Plesk let you enable the MySQL extension with a single click. This is the safest route for users with limited technical knowledge.
- Log in to cPanel and click “Select PHP Version” in the “Software” section.
- On the screen that opens, switch to the “Extensions” tab.
- In the list, check the boxes next to
mysqli,mysqlndandpdo_mysql.
Enabling Missing Modules in Bulk
On the same screen, also check the other extensions WordPress uses. Missing ones don’t cause this error, but they do cause problems with image uploads or updates.
imagickandgd(required for image processing).curlandmbstring(for external connections and character encoding).zipandzlib(for installing and updating plugins).
Verifying the PHP Extension Directory (extension_dir)
PHP stores extension files in a specific directory. If the server was migrated or PHP was installed manually, this directory path may have been left wrong. When PHP tries to load the mysqli extension and cannot find the corresponding .so (Linux) or .dll (Windows) file, it returns the “missing extension” error.
- Create a text file, write
<?php phpinfo(); ?>in it and upload it to your site’s root directory asinfo.php. - Open
yourdomain.com/info.phpin your browser and search for the “extension_dir” value. - Check whether this path matches the actual PHP extension folder on the server.
Correcting a Wrong Path
If the directory path is wrong, it will affect not just MySQL but all PHP functions. Fixing it may require administrator privileges.
- Contact your server administrator and ask them to restore the PHP configuration to normal.
- If you can, update the
extension_dirline in the php.ini file so it points to the correct path. - If you are on shared hosting, reset the PHP settings with the “Reset to default” option.
Database Server and Availability Tests
If the MySQL service is down or under heavy load, WordPress shows “Error establishing a database connection”, not “missing extension”. If you see this message after enabling the extension, the problem is on the database server; run the checks below.
- Confirm in the hosting panel that the MySQL service status is “Running”.
- Try logging in to phpMyAdmin; if you can’t get in there either, the problem lies with the database server.
- Check server resource usage (CPU/RAM) to see whether MySQL has locked up.
Connection Port and Firewall
If you use a remote database server, the communication ports between the servers must be open. A firewall may be blocking this communication.
- Test that port 3306 is open for inbound/outbound traffic on both the source and destination servers.
- Add your web server’s IP to the list of IP addresses allowed to connect (whitelist).
- If the database connection uses SSL/TLS, check that the certificate is valid.
Source: WordPress server requirements
Frequently Asked Questions
1. Will upgrading the PHP version definitely fix this error?
Not always; if the MySQLi module is not enabled in the new version, the error will persist. After upgrading, you should also check the module.
2. What is the difference between “mysqli” and “mysql”?
The “mysql” extension is outdated and was removed entirely in PHP 7.0; “mysqli” is the current, improved version that is more secure and faster.
3. I don’t have SSH access on shared hosting. What should I do?
In that case, use the PHP Selector in your hosting panel, or open a support ticket and ask the support team to enable the module.
4. Will deleting and re-uploading the wp-config.php file help?
No. Deleting the file wipes out your connection details; it is far more effective to verify the database host and password in the file.
5. Is the “MySQL extension” in the error a WordPress plugin?
No. It refers to PHP’s mysqli extension. It is not installed from the Plugins menu but enabled in the PHP settings of your hosting panel or on the server.
Summary
The WordPress missing MySQL extension error is caused by the mysqli extension being disabled or not installed in the PHP version your site runs on; you fix it by enabling the extension in your hosting panel or installing the php-mysql package. Every time you change the PHP version, check that mysqli is also checked for the new version.
















