Home/Blog/How to Fix “Missing the MySQL Extension” PHP Error in WordPress

How to Fix “Missing the MySQL Extension” PHP Error in WordPress

Missing MySQL extension PHP error fix guide

Your site shows a plain white page with the message: “Your PHP installation appears to be missing the MySQL extension which is required by WordPress.” Nothing loads โ€” not even wp-admin. This missing MySQL extension PHP fix guide explains what the error means (PHP can’t talk to your database), why it usually appears after a PHP version switch, and five ways to enable the missing extension and bring your site back.

What Causes “Missing the MySQL Extension”

WordPress stores everything in a MySQL (or MariaDB) database, and PHP talks to that database through an extension called mysqli (or pdo_mysql), built on the MySQL Native Driver (mysqlnd). If PHP loads without that extension, WordPress can’t reach its database and shows this error before anything else loads. Common triggers:

  • PHP version switched without the extension: the #1 cause โ€” your host upgraded PHP (or you did), and the new version’s binary was installed without the php-mysql/mysqlnd package.
  • mysqli disabled in the control panel: in cPanel’s “Select PHP Version” or CloudLinux’s PHP Selector, the mysqli (or nd_mysqli) checkbox is unticked.
  • php.ini missing the extension line: on localhost stacks (XAMPP/WAMP), extension=mysqli and extension=pdo_mysql are commented out or the extension_dir path is wrong.
  • Old WordPress on new PHP: very old WordPress versions used the removed mysql_* functions โ€” a modern PHP has no such extension, so the error appears together with other PHP errors.
  • Web server pointing at the wrong PHP pool: PHP 8.2 may have mysqli enabled, but if Nginx/Apache routes requests to a PHP 8.1 FPM pool that lacks it, the error still appears.
  • Docker or custom build missing it: containers built without the MySQL extension in the image show this error from the start. More database guides live on the KamiWeb blog.

How to Fix “Missing the MySQL Extension”

Since this error appears before WordPress loads, you fix it at the server level โ€” wp-admin is inaccessible, so don’t look for a dashboard setting. Verify first with a tiny test file: create a file containing <?php var_dump(extension_loaded("mysqli")); ?>, open it in your browser, then delete it. If it shows bool(false), the extension is truly missing. Our free web tools can help you check other site basics once you’re back online.

Enabling PHP MySQL extension in server settings concept

  1. Enable mysqli in your hosting panel (shared hosting). In cPanel, go to Software โ†’ Select PHP Version (or MultiPHP Manager โ†’ note your PHP version, then PHP Options). Tick the mysqli checkbox โ€” and on CloudLinux, tick mysqlnd, nd_mysqli, and nd_pdo_mysql (untick plain mysqli/pdo_mysql if both appear; the nd_ versions replace them). Save and refresh your site โ€” this fixes it for most shared-hosting users.
  2. Install the MySQL extension package (VPS/dedicated). On Ubuntu/Debian run sudo apt install php8.3-mysql (match your PHP version), on AlmaLinux/Rocky run sudo dnf install php-mysqlnd, then restart PHP-FPM and your web server (systemctl restart php8.3-fpm). This installs mysqlnd, which enables both mysqli and pdo_mysql.
  3. Enable it in php.ini (localhost: XAMPP/WAMP). Stop Apache, open the correct php.ini (e.g. xampp/php/php.ini โ€” not the -development one), and make sure these lines are uncommented: extension=mysqli, extension=pdo_mysql, and a correct extension_dir = "ext" path. Save, restart Apache/MySQL, and re-check your test file.
  4. Match the web server to the right PHP version. If one PHP version has mysqli and the error persists, your web server may be routing requests to a different PHP-FPM pool. Check that Nginx/Apache points to the same PHP version you configured โ€” in MultiPHP Manager, re-assign the domain’s PHP version explicitly, then restart the web server.
  5. Update WordPress and PHP together. If the error comes with other PHP warnings, you may be running an ancient WordPress on modern PHP. Update WordPress core to the latest version (it uses mysqli throughout) and keep PHP on a supported release (8.1+). If nothing above works, contact your host โ€” a missing extension package is a two-minute fix on their end. Browse KamiWeb’s plugin resources for maintenance tools.

Conclusion

The missing MySQL extension PHP fix is a server configuration task, not a WordPress bug: enable mysqli/mysqlnd in your hosting panel, install the php-mysql package on your server, or uncomment the extension lines in php.ini on localhost. Once extension_loaded("mysqli") returns true, WordPress connects to its database and your site loads again. More fixes at KamiWeb.