could not find driver 🐘 PHP

PDOException: could not find driver

The PDO driver for your database (pdo_mysql, pdo_pgsql, pdo_sqlite) isn’t installed or enabled.

Seen on: PHP

Meaning

PDO is a wrapper; each database needs its own extension. CLI and the web server may load different php.ini files, so it can work in one and fail in the other.

Common causes

  • pdo_mysql / pdo_pgsql extension not installed
  • Extension installed for a different PHP version
  • Enabled for CLI only
  • Docker image without the extension

⚡ Quick fix

  1. Install the extension: sudo apt install php8.2-mysql
  2. Enable it in php.ini (extension=pdo_mysql)
  3. Restart PHP-FPM / Apache
  4. In Docker: docker-php-ext-install pdo_mysql

Detailed fix by platform

Docker

  1. RUN docker-php-ext-install pdo pdo_mysql in the PHP image Dockerfile

How to diagnose

  1. Driver — Which DSN prefix (mysql:, pgsql:)?
  2. Loaded — php -m and phpinfo() from the web server

🧠 Still stuck? Analyze your error

Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.