Skip to content
Docs

could not find driver (Connection: mysql)

PHP needs its database extension, pdo_mysql or pdo_pgsql. Require it in composer.json, or tick it under PHP extensions, and build again.

Updated 17 Oct 20261 min read

The fix on Tanzahost: give your app's PHP the extension for its database, then build again. The simplest way is in your code, in composer.json, so it's there on every build:

json
{
  "require": {
    "php": "^8.4",
    "ext-pdo_mysql": "*"
  }
}

For PostgreSQL, require ext-pdo_pgsql instead. Run composer update --lock on your computer so composer.lock agrees, commit both files, and push.

Or, without changing your code: open the app. Under PHP extensions, tick pdo_mysql (or pdo_pgsql), then under Build and run choose Save and build.

Why it happens

Laravel talks to MySQL, MariaDB and PostgreSQL through PHP's PDO drivers, and "could not find driver" means PHP has no driver for the database in DB_CONNECTION. On Tanzahost your app's PHP has the extensions every PHP comes with (mbstring, curl, openssl, pdo, pdo_sqlite and the rest), plus the ones you ask for. A database's driver is one you ask for:

Your databaseThe extension
MySQL or MariaDBpdo_mysql
PostgreSQLpdo_pgsql
Valkey, through Laravel's default clientredis

We read your composer.json: every ext- it requires that's on our list is added when we build. So the error usually shows up the first time a database is attached, because Laravel's new projects start on SQLite, which needs nothing extra.

How to check

  1. Open the build's log. A step "Adding PHP extensions:" lists the ones the build added. If yours isn't there, it wasn't asked for.

  2. In the app's terminal, list PHP's extensions and look for yours:

Terminal
php -m