Fixing magento issues

How to fix pdo_mysql extension is not installed magento 2

Pinterest LinkedIn Tumblr

Pdo_mysql extension is not installed Magento 2 is a common error message Magento 2 users will probable encounter when working with Magento 2.

You may see this error message when:

  • Execute Magento 2 command from CLI like: php bin/magento setup:static-content:deploy . The error message will stop the command and it looks like this:

pdo mysql extension not installed

  • Install Magento 2 via web wizard (Magento 2.3 and earlier). The error message will be displayed in Step 2: add a database, it looks like this:

web wizard magento 2 install pdo mysql extension not installed

In this tutorial, we will digging into this issue and learn how to fix it properly.

Cause of the error

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

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


To solve this issue, we need to install and enable Pdo_mysql extension.

Step 1: Check if the Pdo_mysql extension is installed but not enabled on your server

Connect to your server using SSL protocol and run this command to check if pdo_mysql is installed

php -m

If PDO is installed, you will see it in the list

By default, the extension is enabled after installing. But in some cases, the extension is disabled. We will have to enable the extension manually. Run this command to check if the extension is enabled:

php -i |grep PDO

If you see this screen => Pdo extension is enabled:

pdo enabled

Else, run the following command to enable pdo_mysql extension

phpenmod pdo_mysql

Step 2: Install pdo_mysql extension

In case the pdo_mysql extension is not installed on your server, we will need to install it first.

Connect to your server using ssh protocol, in CLI interface execute this command:

sudo apt-get install php-mysql

In case the command does not work, check your php version

php -v

check php version

Then run

sudo apt-get install php8.0-mysql

Fix Pdo_mysql extension not installed on localhost environment

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

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

Also, remember to enable pdo_mysql extension in php.ini file on Windows by adding this line


Wrapping up

If you follow my tutorial but the issue pdo_mysql extension is not installed still persists, feel free to drop a comment describe your problem and I will be happy to help

There are many type of error when working with Magento 2, I have made many articles on how to fix various Magento 2 issue on this page

Good luck!


Hung Tran is the main editor of, he loves to write about everything related to Magento 2

Write A Comment