pdo_mysql extension is not installed : How to fix this issue in Magento 2

pdo_mysql extension is not installed is a common error message that users will probably face when working with Magento 2. In this tutorial, Magesolution will dig into this common issue and learn how to fix it properly.

What is pdo_mysql extension is not installed error in Magento 2

This message error is from the PHP side. Basically, there are mainly 2 scenarios behind this error. While adding the database at the time of Magento 2 installation, this error happens after the readiness check.

pdo_mysql extension is not installed

Besides,  when you run the syntax php bin/magento setup:static-content:deploy from the command line. You can check this issue in the below screenshot:

Cause of the pdo_mysql extension is not installed error

The cause of the issue is clearly described in the error message: The pdo_mysql extension is not installed.

Pdo_mysql extension applies the PHP Data Objects (PDO) interface to enable access from PHP to MySQL databases. Without the Pdo_mysql extension, PHP and MYSQL will not work correctly together, that’s why Magento shows that error message when the Pdo_mysql extension is not installed on your server.

How to fix the pdo_mysql extension not installed in Magento 2?

pdo_mysql

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

sudo phpenmod pdo_mysql

If the above way doesn’t work, then this module has not been installed. In this case, install the module from your server’s syntax (with sudo) (*):

sudo apt-get install php7.0-mysql

In this tutorial, we use PHP version 7.0. In case you are using a different PHP version, please change the command line properly

Besides, there’s been recent feedback about the following error when following our method

Unable to acquire the dpkg frontend lock (/var/lib/dpkg/lock-frontend)

Note:  This is the most common issue when you run process(es) in the background. In order to list any process that is accessing the file, you can run the below command

sudo lsof /var/lib/dpkg/lock-frontend 

and use sudo kill to kill process_id:

sudo kill -9 process_id

After that, you need to remove and reconfigure the dpkg frontend lock:

sudo rm /var/lib/dpkg/lock-frontend
sudo dpkg --configure -a

And ultimately, follow the update command and see if the issue is handled for you:

sudo apt update

Fix Pdo_mysql extension not installed on a localhost environment

In case the pdo_mysql extension is installed on your localhost but you can’t use the command, you can follow this syntax:

php -dmemory_limit=6G bin/magento setup:static-content:deploy

Moreover, you need to remember to enable the pdo_mysql extension in the php.ini file on Windows by adding this line

extension=php_pdo_mysql.dll

Read more

Conclusion

That’s all about how to fix the “pdo_mysql extension is not installed” error we want to share with you. If any make you feel not understood or confused, don’t hesitate to leave the question or common for us. Besides, if you are looking out for a cost-effective Magento solution for your eCommerce store, then Magesolution will be an ideal choice. We not only offer an affordable Magento Website Development service for all sizes and budgets but also ensure that it helps your online business leverage to the next level. Contact us for a free consultation!