WordPress is a popular content management system that requires PHP and MySQL to function. However, sometimes you may encounter an error message that says “Your PHP installation appears to be missing the MySQL extension which is required by WordPress”. This error occurs when the PHP installation on your server is missing the MySQL extension, which is required by WordPress to connect to the MySQL database.
In this guide, we will show you how to fix this error.
Step 1: Check if the MySQL extension is installed
The first step is to check if the MySQL extension is installed on your server. You can create a PHP file with the following code to check:
<?php phpinfo(); ?>
Save the file and upload it to your server. Then, open the file in your web browser and search for “MySQLi”. If it is not present, then the MySQL extension is not installed on your server.
Step 2: Install the MySQL extension
To install the MySQL extension, you need to log in to your server as root or a user with sudo privileges. Then, run the following command:
sudo apt-get install php-mysql
This command will install the MySQL extension for PHP on your server.
Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * base: mirror.upsi.edu.my * epel: ftp.cuhk.edu.hk * extras: mirror.upsi.edu.my * updates: mirror.upsi.edu.my Setting up Install Process Resolving Dependencies --> Running transaction check ---> Package php-mysql.x86_64 0:5.3.3-22.el6 will be installed --> Processing Dependency: php-pdo(x86-64) for package: php-mysql-5.3.3-22.el6.x86_64 --> Running transaction check ---> Package php-pdo.x86_64 0:5.3.3-22.el6 will be installed --> Finished Dependency Resolution Dependencies Resolved ==================================================================================================== Package Arch Version Repository Size ==================================================================================================== Installing: php-mysql x86_64 5.3.3-22.el6 base 81 k Installing for dependencies: php-pdo x86_64 5.3.3-22.el6 base 75 k Transaction Summary ==================================================================================================== Install 2 Package(s) Total download size: 155 k Installed size: 383 k Is this ok [y/N]: y Downloading Packages: (1/2): php-mysql-5.3.3-22.el6.x86_64.rpm | 81 kB 00:00 (2/2): php-pdo-5.3.3-22.el6.x86_64.rpm | 75 kB 00:00 ---------------------------------------------------------------------------------------------------- Total 137 kB/s | 155 kB 00:01 Running rpm_check_debug Running Transaction Test Transaction Test Succeeded Running Transaction Installing : php-pdo-5.3.3-22.el6.x86_64 1/2 Installing : php-mysql-5.3.3-22.el6.x86_64 2/2 Verifying : php-pdo-5.3.3-22.el6.x86_64 1/2 Verifying : php-mysql-5.3.3-22.el6.x86_64 2/2 Installed: php-mysql.x86_64 0:5.3.3-22.el6 Dependency Installed: php-pdo.x86_64 0:5.3.3-22.el6 Complete!
Step 3: Restart the System
After the installation is complete, restart your web server to apply the changes:
sudo systemctl restart apache2
Step 4: Test
To test if the MySQL extension has been installed and the error has been resolved, navigate to your WordPress site and refresh the page. If the error message no longer appears, then the issue has been resolved.
Commands Mentioned:
- phpinfo() – displays PHP configuration information
- sudo apt-get install php-mysql – installs the MySQL extension for PHP on Ubuntu or Debian-based systems
- sudo systemctl restart apache2 – restarts the Apache web server
Conclusion:
In this guide, we have shown you how to fix the “Your PHP installation appears to be missing the MySQL extension which is required by WordPress” error. By checking if the MySQL extension is installed, installing it if necessary, and testing your WordPress site, you can resolve this error and ensure that your WordPress site is functioning correctly.
1 Comment
If your site is on Hostgator, you don’t have this option to any longer to check those boxes. The fix I found is to update to the latest version of PHP using Hostgator’s “MultiPHP Manager” in cPanel. Then, rename php.ini to php.bak (this effectively deletes the file that is causing the problem).