How to fix "Your PHP installation appears to be missing the MySQL extension" in WordPress
The PHP that runs the site has no mysqli extension loaded, so WordPress cannot reach its database and stops before it does anything else. Nothing is lost. Switch mysqli on for the PHP version the site really runs, in the hosting panel or through the host.
- By
- WP Ministry
- Published
- Tested on
- WordPress 7.1.3, PHP 8.3.35
In short
- Nothing is lost. WordPress stopped before it opened the database or changed a file.
- WordPress tests for one thing, PHP's mysqli extension. mysqlnd in a list of modules is the driver under it and does not count.
- Look at what changed in PHP. A version chosen in the hosting panel has its own list of extensions, and mysqli may be off in it.
- The panel shows what was asked for. A five-line file in the site's folder shows what the site really runs.
- The command line can run a different PHP from the website, so WP-CLI can print the message while the site works, and the other way round.
- A WordPress older than 3.9 prints it on every PHP from 7.0 on, whatever is loaded.
WordPress prints this when the PHP that is running it has no mysqli extension loaded. mysqli is the part of PHP that talks to a MySQL or MariaDB database. WordPress checks for it before it does anything else, and without it there is no way to reach the database, so it stops and says so.
Nothing is lost. WordPress stopped before it opened the database or changed a file. The site comes back as soon as the PHP behind it has mysqli again.
The fault is in how PHP is set up on the server. Ask what changed there: a new PHP version chosen in the hosting panel, a move to another server, an upgrade of the server's software. It is a different fault from "Error establishing a database connection", where PHP has the extension and the database does not answer.
What you see
Since WordPress 6.2 the message is a plain page titled "Requirements Not Met", with three paragraphs:
Your PHP installation appears to be missing the MySQL extension which is required by WordPress.
Please check that the mysqli PHP extension is installed and enabled.
If you are unsure what these terms mean you should probably contact your host. If you still need help you can always visit the WordPress support forums.It shows on every address of the site: the front page, the login page, the dashboard, the REST API. The server sends it with status 500.
WordPress 5.3 to 6.1 shows the first sentence alone on the same kind of page. Older versions print that sentence as a bare line of text. WP-CLI prints all three after the word "Error:".
What WordPress tests for
The sentence has not changed since WordPress 3.0. What it tests has.
| WordPress | What it looks for |
|---|---|
| 6.4 and later | the function mysqli_connect(), which the mysqli extension provides |
| 6.2 and 6.3 | mysqli_connect() or mysql_connect() |
| 4.5 to 6.1 | any of three extensions: mysql, mysqli or mysqlnd |
| 3.9 to 4.4 | mysql or mysqli |
| 3.8 and older | mysql and nothing else |
Three things follow from the table.
- On any PHP from 7.0 on,
mysqliis the one that counts. The oldmysqlextension was deprecated in PHP 5.5 and removed in PHP 7.0, andmysql_connect()went with it. mysqlndin a list of loaded modules is not enough. It is the driver thatmysqliis built on. PHP's manual says it "does not provide a new API to the PHP programmer", and WordPress's hosting handbook says "mysqlnd is not a standalone replacement for mysqli". A PHP can have the driver loaded andmysqlimissing.- WordPress 4.5 to 6.1 can fail with a different message for the same cause. On a PHP with the driver and no
mysqli, those versions pass the test, go on to connect, and stop with the fatal errorCall to undefined function mysql_connect(). If that line is in your error log, the fixes on this page apply. "There has been a critical error on this website" shows where to read the log.
WordPress skips the test when a database drop-in, wp-content/db.php, is present.
Where it goes wrong
A page request passes through each of these in turn. This one comes from PHP, the language WordPress runs on.
- Browser
- DNS
- HTTPS
- CDN or firewall
- Web server
- PHP (this error comes from here)
- WordPress
- Database and files
What causes it
The PHP version the site runs has mysqli switched off or not installed
CommonEach PHP version on a server has its own extensions. After a change of version in the hosting panel, a move to another server or an upgrade of the server's packages, the PHP now in use can be one that was never given mysqli.
Fix: See what the PHP behind the site has loaded, or Switch mysqli on for the PHP version the site runs, or On your own server, install mysqli and restart PHP
A php.ini or an .htaccess line left from the old PHP version is still in force
SometimesA php.ini in the account replaces the server's own, and one written for another PHP version sends PHP to that version's folder of extensions, where it finds nothing it can load. A line in .htaccess can keep the site on a PHP version other than the one the panel shows.
Fix: See what the PHP behind the site has loaded, or Take a leftover php.ini out of the way, or Remove what keeps the site on another PHP version
Only WP-CLI or a scheduled command prints it, because the command line runs a different PHP
SometimesThe website and the command line are two PHP programs, each with its own configuration. One can have mysqli while the other does not.
Fix: See what the PHP behind the site has loaded, or Run WP-CLI with the PHP the site uses
WordPress is older than 3.9 and PHP is 7.0 or newer
RareWordPress before 3.9 asks only for the old mysql extension, which PHP removed in 7.0. On any PHP since, it prints the message even when mysqli is loaded.
Fix: See what the PHP behind the site has loaded, or Bring a WordPress older than 3.9 up to date
How to fix it
See what the PHP behind the site has loaded
- Easy
- No risk
- About 10 minutes
- Steps tested on WordPress 7.1.3
The hosting panel shows what it was asked to set up. This shows what the site really runs, and it tells you which of the other fixes you need.
Step 1: Make a file named mysqli-check.php
Put it in the folder WordPress is installed in, beside
wp-config.php. Use your host's file manager, or connect over SFTP. This is the whole file:mysqli-check.php<?php header( 'Content-Type: text/plain; charset=utf-8' ); echo 'PHP version: ', PHP_VERSION, "\n"; echo 'Runs as: ', PHP_SAPI, "\n"; echo 'mysqli: ', function_exists( 'mysqli_connect' ) ? 'loaded' : 'missing', "\n"; echo 'php.ini: ', php_ini_loaded_file() ?: 'none', "\n"; echo 'Extension folder: ', ini_get( 'extension_dir' ), "\n";Step 2: Open it in your browser
Its address is your site's address followed by
/mysqli-check.php, for examplehttps://example.com/mysqli-check.php. It runs without WordPress, so it works while the site is down. On a server where nothing is wrong it prints five lines like these:textPHP version: 8.3.35 Runs as: apache2handler mysqli: loaded php.ini: none Extension folder: /usr/local/lib/php/extensions/no-debug-non-zts-20230831Step 3: Read the five lines
- mysqli says
missingwhen the message is right. It asks PHP the same question WordPress 6.4 and later asks. If it saysloadedand the site still shows the message, WordPress is older than 3.9: go to the last fix. - PHP version is the version this folder really runs. If it is not the one your hosting panel shows, something is holding the site on another version: go to "Remove what keeps the site on another PHP version".
- php.ini is the main configuration file PHP read. A path inside your own account, such as your home folder or the site's folder, means a file of yours has replaced the server's: go to "Take a leftover php.ini out of the way".
- Extension folder is where PHP looks for
mysqli. If the path names a PHP version, it should be the version on the first line. A different one means PHP is looking among another version's extensions. - Runs as says how the web server starts PHP.
apache2handleris PHP inside Apache, which reads its configuration once, when the web server starts.cgi-fcgiis PHP's CGI program.fpm-fcgiandlitespeedare two more names you may see.
- mysqli says
Step 4: Delete the file
It tells anyone who opens it how the server is set up. Delete it as soon as you have read it, in the file manager or over SSH from the WordPress folder:
bashrm mysqli-check.php
Over SSH, three commands answer the same questions for the command line. The first prints mysqli when the extension is loaded and nothing when it is not. Search for mysqli, not mysql: the driver's name, mysqlnd, contains "mysql" too.
php -m | grep -i mysqliThe second lists the php.ini in use and every additional .ini file PHP read. Where extensions are installed as packages, one of those small files is what loads mysqli.
php --iniThe third is WP-CLI's own report. Read the lines "PHP binary" and "php.ini used".
wp --infoTo undo it: Delete mysqli-check.php from the server.
Switch mysqli on for the PHP version the site runs
- Easy
- Low risk
- About 10 minutes
A server keeps a set of extensions for each PHP version. The version you have just moved to may not have what the old one had.
Step 1: Open the PHP settings in your hosting panel
The name differs from host to host. On hosts that use CloudLinux's PHP Selector with cPanel it is Select PHP Version, in the Software section. Its documentation describes a "PHP Extensions" page where "you can choose extensions for the particular PHP version".
cPanel's own MultiPHP Manager sets the PHP version for a domain, and its documentation describes no list of extensions. On those servers an extension is a package that the server's administrator installs.
Step 2: Check the version first
Make sure the panel shows the version you meant to choose, and that it matches the "PHP version" line of the check file.
Step 3: Tick mysqli
In the list of extensions, tick
mysqli. CloudLinux's list can also havend_mysqli: its documentation says that for a PHP version that has it, its installer switchesnd_mysqlion andmysqlioff unless the server's owner has set other defaults. Ticknd_mysqliif the list has it, otherwisemysqli. Save if the panel has a save button. In PHP Selector, changes are saved as you make them.Step 4: Reload the site
If the message is still there, open the check file again. Once it says
loaded, WordPress gets past this check.Step 5: If there is no such list, write to the host
Send the exact message, the PHP version from the check file, and when it began. Ask them to enable the
mysqliextension for that PHP version on your account. WordPress hosting problems: how to tell whether the fault is the host or the site has a message you can copy and adapt.Step 6: Meanwhile, set the PHP version back
If the site worked on the previous version, choosing it again brings the site back while you wait. Treat that as temporary if the old version is past its end of life. The WordPress and PHP end-of-life checker shows which versions still get security fixes.
To undo it: Set the PHP version back to the one the site ran on, or clear the box you ticked.
Take a leftover php.ini out of the way
- Takes care
- Low risk
- About 10 minutes
- Steps tested on WordPress 7.1.3
PHP looks for its main configuration file in a list of places, in order, and uses the first one it finds. Ahead of the server's own place, the list has the folder named in an environment variable, PHPRC, and, except on the command line, the folder PHP is working in. A php.ini found in either is used in place of the server's. Hosting panels write such files: cPanel's MultiPHP INI Editor saves a php.ini in a domain's folder or in the home directory.
A file like that outlives the PHP version it was written for. If it sets extension_dir to the old version's folder, the new PHP looks there for mysqli and cannot load it. The server's error log then has a line that starts like this, followed by the folder it tried:
PHP Warning: PHP Startup: Unable to load dynamic library 'mysqli'Step 1: Find the file
The "php.ini" line of the check file names the one in use. Otherwise look for a file named
php.iniin the WordPress folder and in your account's home folder.Step 2: See what it says about extensions
Open it and search for the word "extension". Over SSH, from the folder the file is in:
An
extension_dirline with a path that belongs to another PHP version is the fault. So areextension=lines that name files the new version does not have.If the check file names this file as the
php.iniin use, go on to rename it even when the search prints nothing. CloudLinux's documentation notes that beside a customphp.inithe server's additional.inifiles may not be loaded, and those are what load the extensions.bashgrep -n -i "extension" php.iniStep 3: Rename it
Renaming keeps the file, so you can read your old settings from it later.
PHP no longer finds a
php.inithere and goes back to the server's own. cPanel's documentation gives the same advice for its editor: to reset PHP's settings to their defaults, delete the domain's or the home directory'sphp.inifile.bashmv php.ini php.ini.offStep 4: Reload the site
PHP's CGI program reads its configuration each time it is started, so the change shows on the next request or soon after. Where PHP stays running between requests, it shows when PHP is next restarted. Your panel may have a button for that, or the host can do it.
Step 5: Set again what you still need
The old file may also have raised the memory limit or the upload size. Set those again in the panel's PHP options, for the version you are on now.
Leave .user.ini alone. PHP reads only some settings from that file, and neither extension nor extension_dir is among them, so it cannot cause this message.
To undo it: Rename php.ini.off back to php.ini.
Remove what keeps the site on another PHP version
- Takes care
- Back up first
- About 15 minutes
Use this when the check file shows a PHP version that is not the one in your hosting panel. You switched mysqli on for one version, and the site runs another.
Some panels write the choice of PHP version into .htaccess. cPanel's documentation says that when you set a domain's PHP version the system creates its .htaccess file, and that a domain set to inherit takes its version from the first .htaccess with PHP version information that Apache finds on the way up through the folders. A line left in the site's folder, or in a folder above it, can therefore decide the version.
Step 1: Download a copy of .htaccess
It is in the WordPress folder. It may be hidden: turn on "show hidden files" in the file manager.
Step 2: Set the PHP version again in the panel
Choose the version you want and apply it, even if the panel already shows it. That makes the panel write its own lines again. cPanel recommends setting the version only through its interface, and warns that a version set by hand may behave unexpectedly.
Step 3: Look for lines the panel did not write
In
.htaccessin the WordPress folder and in each folder above it, look for lines that name a PHP version or a path to aphp.ini: lines that beginAddHandlerorSetHandlerand mention PHP, and lines withsuPHP_ConfigPath,PHPRCorlsapi_phprc. CloudLinux's documentation tells server owners not to redefine the path tophp.iniwith settings such asSuPHP_ConfigPathandPHPRC, because doing so can break its PHP Selector.Step 4: Remove a line that points at the old version, and reload
Remove one line at a time and reload the site after each. If the site answers with a server error, put the line back from your copy.
Step 5: Run the check file again
The "PHP version" line should now match the panel.
To undo it: Upload the copy of .htaccess you downloaded.
On your own server, install mysqli and restart PHP
- Advanced
- Low risk
- About 15 minutes
This is for a server you administer yourself. On shared hosting, use the hosting panel fix above.
Step 1: Install the package for the PHP version the site runs
PHP's manual says that on Linux the MySQL extensions "may need to be installed using an additional package", and to look in the distribution's package manager. On Ubuntu:
That package is for the distribution's default PHP. Where a server has more than one PHP version, each has a package of its own with the version in its name, such as
php8.3-mysql. Install the one that matches the "PHP version" line of the check file. On Fedora the package isphp-mysqlnd. On a cPanel server the administrator installs PHP extensions in WHM's EasyApache 4 interface.bashsudo apt install php-mysqlStep 2: Or switch it on in php.ini
Where PHP was installed without a package manager, as on Windows, the extension is a line in
php.ini. The file PHP ships with has it commented out with a semicolon, as;extension=mysqli. Remove the semicolon so the line reads:php --inishows whichphp.inithe command line reads. The check file shows which one the website reads.php.iniextension=mysqliStep 3: Restart the web server
PHP inside a web server reads its configuration once, when the web server starts. Until a restart, nothing changes. On Ubuntu with Apache:
If the site uses PHP-FPM, restart that service too.
bashsudo systemctl restart apache2.serviceStep 4: Run the check file again
It should now say
mysqli: loaded.
To undo it: Remove the package with the same package manager, or put the semicolon back, and restart the web server again.
Run WP-CLI with the PHP the site uses
- Takes care
- No risk
- About 10 minutes
Use this when the site loads and only WP-CLI, or a scheduled command, prints the message.
Step 1: See which PHP WP-CLI found
Run
wp --infoand read the "PHP binary" line. That is the program WP-CLI started with, usually the firstphpin your shell's search path.Step 2: Find the PHP the website uses
The check file gives its version. Your host's documentation, or the host, can give the path of the command-line program for that version. A server with several versions keeps each in a folder of its own: CloudLinux's documentation shows paths such as
/opt/alt/php72/usr/bin/php.Step 3: Run WP-CLI with that PHP
Put the path of that PHP before the path of WP-CLI's file.
which wpprints the second."PHP binary" should now be the one you named. Use the same form for any other command, and in a scheduled command, where the search path can differ from your shell's.
bash/path/to/php /path/to/wp --infoStep 4: Make it the default
WP-CLI's handbook says to put the folder of the PHP you want first in your
PATH, in your shell's profile. ItsWP_CLI_PHPsetting works only when WP-CLI was not installed as a Phar file, and the Phar is the install its handbook recommends.
If the command line's PHP is the right version and simply lacks mysqli, ask the host to enable the extension for the command line as well, or on your own server install the package for that version. How to use WP-CLI to manage a WordPress site covers connecting and checking the install.
To undo it: Nothing on the site is changed. Take the line out of your shell profile if you added one.
Bring a WordPress older than 3.9 up to date
- Advanced
- Back up first
- About 60 minutes
To see which WordPress the site runs, open wp-includes/version.php and read the line that begins $wp_version.
WordPress 3.8 and older asks PHP for the mysql extension by name and for nothing else. PHP removed that extension in 7.0. On any PHP since, such a WordPress prints the message whatever is loaded, and no extension setting changes that. It cannot run its own updater either, because it stops before the dashboard loads.
Step 1: If the host still offers the PHP the site last ran on
Set the PHP version back. The site loads again, and you have the dashboard to back up and update from. Treat it as a stopgap. A PHP from before 7.0 is years past its end of life, and current WordPress needs PHP 7.4 or later, so the site has to move forward in the end. The WordPress and PHP end-of-life checker shows where each version stands.
Step 2: Otherwise, replace WordPress's files by hand
WordPress's documentation calls this a manual update. Download the current WordPress. On the server, delete the old
wp-includesandwp-adminfolders and upload the new ones. Upload the new files from the top folder over the old ones. Keepwp-config.phpand thewp-contentfolder as they are.Step 3: Update the database
Open
/wp-adminon your site. WordPress sees that the database is older than the files and gives you a link towp-admin/upgrade.php. Follow it.Step 4: Expect the theme and plugins to need work
Code from the same years as that WordPress may stop on a current PHP. If the site then shows "There has been a critical error on this website", that page shows how to find the plugin or theme and switch it off from outside.
How to safely update WordPress, plugins and themes covers backing up and updating one thing at a time once the site is running.
To undo it: Restore the files and the database from the backup you took before you began.
When to get help
Stop when the panel has no setting for extensions and the host will not switch mysqli on, when the check file says mysqli is loaded and the message is still there, or when the site runs a WordPress from before 3.9 that has to be brought forward many years in one step. Each needs access to the server and a backup taken first. On a store, stop sooner. No order can be placed while the message shows.
Common questions
Is my content gone?
No. WordPress made this check before it connected to the database, and it wrote nothing. Posts, pages, users, settings and uploads are as they were.
The module list shows mysqlnd, or pdo_mysql. Why does WordPress still say MySQL is missing?
WordPress tests for the function mysqli_connect(), which only the mysqli extension provides. mysqlnd is the driver under it and pdo_mysql is a different extension. Neither one gives WordPress what it asks for.
Why does WP-CLI print the message when the site works?
The command line is running a different PHP program from the website, or the same one with a different configuration, and that one has no mysqli. wp --info shows which PHP and which php.ini WP-CLI used.
Can I fix it from wp-config.php, .htaccess or a plugin?
No. PHP loads extensions only when it starts, from php.ini: its manual marks the extension setting as changeable in "php.ini only". WordPress runs this check before it loads any plugin. The change has to be made where PHP is configured, which on shared hosting means the panel or the host.
Is this the same as "Error establishing a database connection"?
No. That message means PHP has mysqli and the connection failed: the details in wp-config.php are wrong or the database server is not answering. How to fix "Error establishing a database connection" covers it.

