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

pdo_mysql extension is not installed

pdo_mysql extension is not installed is a common error message which users will probable face when working with Magento 2. In this tutorial, Magesolution will digging 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 scenario behind this error. While adding database at the time of Magento 2 installation, this error happens after readiness check.

pdo_mysql extension is not installed

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

pdo-mysql-extension-not-installed-768x192

Cause of the pdo_mysql extension is not installed error

The cause of the issue is clearly described in the error message: 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 Pdo_mysql extension, PHP and MYSQL will not work correctly  together, that’s why Magento shows that error message when Pdo_mysql extension is not installed on your server.

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

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 have 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 a 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 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 localhost environment

In case 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 pdo_mysql extension in php.ini file on Windows by adding this line

extension=php_pdo_mysql.dll

Read more

Magento database configuration: The simple guide to change it in Magento 2

Required parameter ‘theme_dir’ was not passed: How to fix this issue in Magento 2

203 Total Views 8 Views Today