How to Fix the Missing MySQL Extension Error in WordPress



If you are setting up WordPress on a new Linux VPS for the first time you may face some problems like missing some PHP extensions. One example is missing the MySQL extension and this is a common problem since the extension doesn’t come by default with many operating systems. In this tutorial we will help you to fix the problem with the missing extension and complete the WordPress installation successfully.

Missing a PHP extension is not something you should be worried about. If you see the following message on your screen when trying to access the WordPress installation via web browser, then you are one of the many WordPress users facing the same problem.

Your PHP installation appears to be missing the MySQL extension which is required by WordPress.

To fix the problem, you should have a SSH access to the server. Connect to your Linux VPS via SSH and check the PHP version which is currently in use:

php -v

You can also check the PHP version by creating a simple info.php file in your public_html directory with the following content:

<?php phpinfo(); ?>

Once you create the file, open your favorite web browser and access the file.

If your are running an Ubuntu VPS and PHP 7, then run the following commands:

apt-get update
apt-get install php7.0-mysql

Then restart your Apache service for the changes to take effect, or if you are using Nginx + PHP-FPM, then restart the PHP-FPM service.

In case you are running PHP 5, run the following commands:

apt-get update
apt-get install php-mysql

Restart the appropriate service for the changes to take effect.

To search all the available packages containing mysql, you can use this command:

apt-cache search mysql

On the other hand, if you are running a CentOS VPS and you have PHP 7 installed on the server, then run the following commands to fix the problem:

yum update
yum install php70w-mysql

Restart Apache or the PHP-FPM service in case you are using Nginx + PHP-FPM as a web server.

If you have PHP 5 installed on your CentOS server, run the following commands:

yum update
yum install php-mysql

Restart the appropriate service for the changes to take effect.

To search all the available packages containing mysql, you can use the following command:

yum search mysql

Once you install the MySQL extension for PHP, you can return back to your WordPress setup. If the installation went OK, the message about the missing extension should not be presented to you. You can now continue with your WordPress setup.

Of course, you don’t have to do any of this if you use one of our Linux VPS Hosting services, in which case you can simply ask our expert Linux admins to help you install the MySQL extension for PHP on your server for you. They are available 24×7 and will take care of your request immediately.

PS. If you liked this post please share it with your friends on the social networks using the buttons on the left or simply leave a reply below. Thanks.

Tutorials
Install Concrete5 on an Ubuntu 14.04 VPS with Nginx, PHP-FPM and MySQL
Tutorials
How to install Piwik on a CentOS VPS
Tutorials
Install Odoo 9 on Ubuntu 14.04
There are currently no comments.