How to enable the pdo_mysql PHP extension Print

  • php, pdo_mysql, php extensions, mysql
  • 28

pdo_mysql is the PHP extension most content management systems and frameworks use to talk to MySQL. If your application reports that it is missing, it has to be enabled for the PHP version your site actually runs.

Through a control panel

Each panel has its own place for this, and in each case the extension is enabled per PHP version, not per site:

If the site still does not see the extension after you have enabled it, check which PHP version that domain uses. Enabling it for 8.3 does nothing for a site running on 8.1.

On a server without a panel

Debian and Ubuntu — with the version matching the one your site uses:

apt install php8.3-mysql
systemctl restart php8.3-fpm

AlmaLinux, Rocky Linux and other RHEL-based systems:

dnf install php-mysqlnd
systemctl restart php-fpm

On these systems the package is php-mysqlnd and it provides both pdo_mysql and mysqli. On Debian and Ubuntu the equivalent package is php-mysql, likewise providing both.

If your server runs alternative PHP versions from a separate repository, the package name carries the version prefix instead — for example php83-php-mysqlnd from Remi. Installing the extension for the wrong version is the usual reason this appears not to work.

Checking the result

php -m | grep pdo

This shows what the command-line PHP has loaded, which is not necessarily the version serving your site. To check what the site sees, create a file in the site root containing <?php phpinfo();, open it in a browser, look for the pdo_mysql section — and then delete the file, since it discloses a great deal about the server.

The simplest check is the application itself: the warning about the missing extension should disappear.

If the extension does not appear

  • PHP was not restarted. The extension is loaded at start-up: restart PHP-FPM, and the web server if the site runs PHP through Apache's module.
  • The wrong version. Confirm which PHP version the domain uses and install or enable the extension for that one.
  • Not available on the server. If the extension is not offered in the panel at all, it is not installed. Open a ticket telling us the extension and the site it is for, and we will add it.

If the application still cannot connect to its database after the extension is loaded, the problem is the connection details rather than PHP — see Creating a database in Plesk for where to find them.


Was this answer helpful?

« Back