How to solve pdo_mysql extension is not installed

What is “pdo_mysql extension is not installed”?

When you install Magento 2, after Readiness Check, you will come to the step Add a Database. The message “pdo_mysql extension is not installed” appears on a red line.

When you run the command php bin/magento setup:static-content:deploy from command line. The message shows:

Why does this happen?

In PHP, there’s a module named php-mysql, which is very important to any PHP servers using mysql to be its database. PHP needs this file to connect with mysql database. When this error occurs, it is likely that this module have not been installed or have been disabled.

How to solve it?

a. The module may be disabled. Run this command to enable it:

sudo phpenmod pdo_mysql

b. If the above method doesn’t work, then this module have not been installed. In this case, install the module from your server’s command line (with sudo) (*):

sudo apt-get install php7.0-mysql

*Note: In this guide we use PHP version 7.0. If you are using a different PHP version, please adjust the command line accordingly.