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
- Install the extension:
sudo apt install php8.2-mysql - Enable it in php.ini (
extension=pdo_mysql) - Restart PHP-FPM / Apache
- In Docker:
docker-php-ext-install pdo_mysql
Detailed fix by platform
Docker
RUN docker-php-ext-install pdo pdo_mysqlin the PHP image Dockerfile
How to diagnose
- Driver — Which DSN prefix (mysql:, pgsql:)?
- Loaded —
php -mand 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.
Was this page helpful?
Report a correction or suggest an improvement
Last updated 2 Oct 2026