Skip to content

Fix "missing the MySQL extension" in WordPress

Fix the WordPress error "Your PHP installation appears to be missing the MySQL extension" by checking which PHP version serves your website and whether it loads mysqli. You will then install or enable the extension on cPanel, CloudLinux or a plain Linux server, and confirm the site loads again.

Every page of your WordPress site now shows the same message, “Your PHP installation appears to be missing the MySQL extension which is required by WordPress”. It can start right after a PHP version change, a server migration or a new EasyApache profile on a cPanel server. The message means the PHP version that serves the website has no mysqli, the PHP extension WordPress uses to talk to its MySQL or MariaDB database. Your database and your content are untouched. The fix is to find which PHP answers web requests for this domain, then install or enable mysqli for that exact version.

What you’ll accomplish

  • See which PHP version serves the site, and whether it loads mysqli.
  • Understand why php -m in a terminal can show mysqli while the website still fails.
  • Match the result to one of five causes.
  • Install or enable the extension on cPanel with EasyApache 4, on CloudLinux PHP Selector, or on a plain Ubuntu, Debian, AlmaLinux or RHEL server.
  • Confirm the fix with a test request and a normal page load.

Prerequisites

  • File access to the site through SSH, cPanel Terminal or cPanel File Manager.
  • For installing packages: root access, or WHM on a cPanel server. On shared hosting, do step 1 yourself and send the result to your host.
  • Example values used below: account atelier, domain example.com, WordPress in /home/atelier/public_html. The site was moved from PHP 8.3 to PHP 8.4. Replace these with your own.

How it works

Early in every request, before it opens the database, WordPress checks that PHP can reach MySQL at all. In WordPress 6.4 and later, the test is whether the function mysqli_connect exists. If it does not, WordPress stops with HTTP status 500 and prints this message. The check and the wording changed over time:

WordPress versionWhat it checksWhat it prints
3.8 and olderThe old mysql extension onlyThe one sentence
3.9 to 6.1mysql or mysqli (later releases also accept mysqlnd)The one sentence
6.2 and 6.3The function mysqli_connect or the old mysql_connectThe sentence, then “Please check that the mysqli PHP extension is installed and enabled.”
6.4 and laterThe function mysqli_connect onlySame as 6.2

PHP removed the old mysql extension in version 7.0, so mysqli is the one that matters today. Since PHP 8.2 it is always built on mysqlnd, the MySQL Native Driver, which is the library that talks to the database server. The cPanel, Debian, Ubuntu and RHEL-family packages ship the two together.

A server often has several PHP versions, and each has its own list of extensions. The web server picks one version per domain. Your terminal may pick another.

A website request for example.com reaches PHP 8.4, the version set for the domain, where mysqli is not loaded and WordPress shows the error. The command php -m in a terminal runs PHP 8.3, the server default, where mysqli is loaded.

Both answers in the diagram are true. Only the left one decides what visitors see.

Step-by-step

  1. Ask the web PHP what it has loaded. Create a small check file in the same folder as wp-config.php, then request it over the web.
cat > ~/public_html/mysqli-check.php <<'PHP'
<?php
header('Content-Type: text/plain');
echo 'PHP = ', PHP_VERSION, "\n";
echo 'SAPI = ', PHP_SAPI, "\n";
echo 'mysqli = ', var_export(extension_loaded('mysqli'), true), "\n";
echo 'mysqlnd = ', var_export(extension_loaded('mysqlnd'), true), "\n";
echo 'php.ini = ', var_export(php_ini_loaded_file(), true), "\n";
echo 'extension_dir = ', ini_get('extension_dir'), "\n";
PHP
curl -s https://example.com/mysqli-check.php

Example output:

PHP = 8.4.27
SAPI = fpm-fcgi
mysqli = false
mysqlnd = false
php.ini = '/opt/cpanel/ea-php84/root/etc/php.ini'
extension_dir = /opt/cpanel/ea-php84/root/usr/lib64/php/modules

Line 3 is the answer. false confirms the web PHP has no mysqli. Line 1 is the version you must fix, and line 5 tells you who provides it. If line 3 says true, the extension is fine, so go to cause E. With no SSH, create the same file in File Manager and open its address in a browser.

  1. Compare with the command line, so it stops misleading you. Run this as the account user:
php -v | head -n 1
php -m | grep -i mysql

Example output:

PHP 8.3.30 (cli) (built: Nov 12 2026 08:17:42) (NTS)
mysqli
mysqlnd
pdo_mysql

Here the terminal runs 8.3 with mysqli, while the website runs 8.4 without it. Trust step 1. On cPanel, the php command is a wrapper that picks a version from the folder you are in. Where no version is set, it uses the server default. Cron jobs and WP-CLI, the wp command, use this command-line PHP too, so they can keep working while the website is down. Our guide on checking which PHP version your site really runs covers this split in detail.

  1. Pick your cause from the check file. Use the first row that matches.
What step 1 printedCause
php.ini under /opt/cpanel/ea-php…A: the EasyApache 4 package is not installed
php.ini under /opt/alt/php…B: the extension is unticked in CloudLinux PHP Selector
php.ini under /etc/php/… or /etc/php.iniC: the distribution package is missing
php.ini inside your home folder, or an extension_dir for another PHP versionD: an old custom php.ini
mysqli = trueE: a very old WordPress

Cause A: the EasyApache 4 package is missing for this version

EasyApache 4 is the part of cPanel that installs Apache and PHP as packages. Each PHP version has its own set, named ea-php plus the version number. The mysqlnd package of a version provides mysqli, mysqlnd and pdo_mysql together. A PHP version added with EasyApache 4’s “PHP only” option comes with its required extensions and nothing more, so it can lack this package. As root, check:

rpm -q ea-php84-php-mysqlnd

Example output:

package ea-php84-php-mysqlnd is not installed

If it prints the package name with a version number, the package is there, so check cause D. To install it, open WHM → Software → EasyApache 4. Click Customize in the Currently Installed Packages section and go to the PHP Extensions step. Search for mysqlnd, select it for the version from step 1, click Next until the Review section, and click Provision. On AlmaLinux or Rocky Linux, the command line does the same job:

dnf install ea-php84-php-mysqlnd

The last line should read Complete!. If the domain uses PHP-FPM (step 1 printed SAPI = fpm-fcgi), restart it so the running workers load the new extension:

/usr/local/cpanel/scripts/restartsrv_apache_php_fpm

Then request the check file from step 1 again. Line 3 should now read true.

Without root access, you can still bring the site back. Open cPanel → Software → MultiPHP Manager, tick the domain, choose the version it used before in the PHP Version menu, and click Apply. Then ask your host to install ea-php84-php-mysqlnd before you switch again.

Cause B: the extension is unticked in CloudLinux PHP Selector

CloudLinux adds its own PHP builds, named alt-php, and a cPanel page called Select PHP Version, where each account picks a version and ticks its extensions. Every version keeps a separate list, so a newly chosen version starts from the server’s default list, which may not include MySQL.

Open cPanel → Select PHP Version and look at the extension list of the current version. CloudLinux offers two sets of MySQL drivers and says they cannot be mixed. Tick mysqlnd, nd_mysqli and nd_pdo_mysql, and leave mysqli and pdo_mysql unticked. If the error stays, CloudLinux’s advice is to switch to the other set, mysqli with pdo_mysql.

As root, you can do the same from the command line. List the MySQL extensions for the account and the version:

selectorctl --list-user-extensions --version=8.4 --user=atelier --all | grep mysql

Example output:

- mysqli
- mysqlnd
- nd_mysqli
- nd_pdo_mysql
- pdo_mysql

A plus sign means enabled and a minus sign means disabled. Here nothing is enabled. Turn on the nd set:

selectorctl --enable-user-extensions=mysqlnd,nd_mysqli,nd_pdo_mysql --version=8.4 --user=atelier

Run the list command again. The three names should now start with +. If the website still shows the error, CloudLinux’s support article gives one more command. It refreshes the account’s CageFS, the private file system that CloudLinux gives each account:

cagefsctl --update-etc atelier && cagefsctl -m atelier

Request the check file from step 1 again. Line 3 should read true.

If Select PHP Version shows the current version as native, the account uses the PHP that cPanel itself provides, which is the EasyApache 4 one. Go back to cause A.

Cause C: the package is missing on a plain Linux server

On a server without a control panel, the distribution’s own package provides the extension. On Ubuntu and Debian the package name contains the PHP version, so use the version from step 1.

sudo apt install php8.4-mysql
sudo systemctl restart php8.4-fpm

On AlmaLinux, Rocky Linux and RHEL, the package is php-mysqlnd:

sudo dnf install php-mysqlnd
sudo systemctl restart php-fpm

In both cases systemctl restart prints nothing when it succeeds. The restart matters, because PHP-FPM loads its extensions only when the service starts. If the site uses Apache’s built-in PHP module instead of PHP-FPM, restart Apache: apache2 on Ubuntu and Debian, httpd on the RHEL family. Then request the check file from step 1 again, and line 3 should read true.

The package must match the version that serves the site. Installing php8.4-mysql does nothing for a site still served by PHP 8.3.

Cause D: an old custom php.ini points at another version

A PHP handler is the method Apache uses to run PHP. With the suPHP and CGI handlers, PHP can load a php.ini file placed in the site’s folder in place of the server’s file. If that file came along in a migration, it can hold an extension_dir line for a PHP version that no longer exists. PHP then looks for mysqli.so in the wrong folder, and the error log gains lines that contain Unable to load dynamic library. Search the account for such settings:

grep -nE "^\s*(extension_dir|extension)\s*=" ~/php.ini ~/public_html/php.ini 2>/dev/null
grep -nE "suPHP_ConfigPath|PHPRC|PHP_INI_SCAN_DIR" ~/public_html/.htaccess 2>/dev/null

Example output:

/home/atelier/public_html/php.ini:14:extension_dir = "/usr/local/lib/php/extensions/no-debug-non-zts-20131226"
/home/atelier/public_html/php.ini:15:extension=mysql.so

Rename the file, then run the curl command from step 1 again:

mv ~/public_html/php.ini ~/public_html/php.ini.old

If mysqli is now true, the old file was the cause. Add back only the settings you still need, such as a memory limit, with cPanel’s MultiPHP INI Editor. If the second grep printed a line, that line in .htaccess sends PHP to a custom configuration path. CloudLinux’s documentation warns that these three settings can break PHP Selector. Put a # in front of the line, save, and test again.

Cause E: a very old WordPress

When step 1 prints mysqli = true and the message stays, look at the WordPress version:

grep "^\$wp_version" ~/public_html/wp-includes/version.php

Example output:

$wp_version = '3.7.41';

WordPress 3.8 and older accept only the removed mysql extension, so they show this message on every PHP 7 or PHP 8 version, with or without mysqli. No package can fix that. Set the domain back to the PHP version it ran on, update WordPress from the dashboard, then move to the new PHP version. If the old PHP is gone from the server, restore the site on a staging copy that still has it, and update there.

Validate it works

  1. Request the check file again. Line 3 must now read true:
curl -s https://example.com/mysqli-check.php | grep mysqli

Example output:

mysqli = true
  1. Load the site and check the status code. The first line should show status 200, or a 301 or 302 redirect if your site forwards to another address.
curl -sI https://example.com/ | head -n 1

Example output:

HTTP/2 200
  1. Log in to the dashboard and open one post in the editor. Every dashboard screen reads the database, so a normal page there confirms the connection.

  2. Delete the check file. It shows server paths to anyone who guesses its name.

rm ~/public_html/mysqli-check.php

Troubleshooting

  • The check file says true, but another site on the account still fails. cPanel sets the PHP version per domain, and a folder’s .htaccess can carry its own PHP handler line. Put the check file in the folder of the site that fails and request it through that site’s own address.
  • You installed the package and the check file still says false. Either the PHP service was not restarted, or the package is for another version. Compare the version in the package name with line 1 of the check file.
  • The message is gone, and the site now says “Error establishing a database connection”. PHP has its database driver now, and the connection itself fails. That is a separate problem with its own causes. Follow our guide to the “Error establishing a database connection” page on cPanel.
  • The site shows a fatal error such as Call to undefined function mysqli_init() and not this message. WordPress skips its own check when a file named db.php exists in wp-content. Some caching and database plugins install that file. The cause and the fix are the same as above.

When this is the wrong approach

Setting the domain back to its previous PHP version is a good way to get the site online quickly. It is a poor permanent answer if that version no longer receives security fixes. Use the time it buys to install the extension on the new version.

If your host manages the server and you have no root or WHM access, stop after step 1 and send them the six lines of output. If WordPress prints a different sentence, such as “Your server is running PHP version”, the PHP version is too old for your WordPress, and this article does not apply.

cPanel’s page on the EasyApache 4 interface and the PHP manual’s mysqli installation notes are the references behind these steps.

Running WordPress that earns real money deserves an operator — Stack Harbor runs that stack under Enterprise WordPress; book an infrastructure consult.