Laravel "could not find driver" (PDO extension) in CI
PDO has no driver registered for the database you configured. The matching PHP extension (pdo_mysql, pdo_pgsql, or pdo_sqlite) is not compiled or enabled in the CI PHP build. Add it to the setup-php extensions list.
What this error means
The first query fails with "SQLSTATE[HY000] ... could not find driver" or "PDOException: could not find driver", regardless of credentials, because the PDO driver extension is missing.
Illuminate\Database\QueryException
could not find driver (Connection: mysql, SQL: select 1)Common causes
The PDO driver extension is not enabled
The CI PHP build lacks pdo_mysql (or pdo_pgsql/pdo_sqlite) for the DB you use, so PDO has no driver to open the connection.
DB_CONNECTION does not match an installed driver
You configured mysql but only pdo_sqlite is present, so PDO cannot construct a mysql connection.
How to fix it
Add the driver via setup-php extensions
- List the PDO driver your DB_CONNECTION needs in setup-php.
- Include the base pdo extension where required.
- Re-run so PHP loads the driver before Laravel connects.
- uses: shivammathur/setup-php@v2
with:
php-version: '8.3'
extensions: mbstring, pdo, pdo_mysql, pdo_sqliteMatch the extension to DB_CONNECTION
For Postgres use pdo_pgsql, for sqlite use pdo_sqlite. Enable the one matching DB_CONNECTION.
extensions: pdo_pgsql # DB_CONNECTION: pgsqlHow to prevent it
- Declare every needed PDO driver in setup-php extensions.
- Keep the enabled driver aligned with DB_CONNECTION.
- Verify with
php -m | grep pdoearly in the job.