-
Notifications
You must be signed in to change notification settings - Fork 11.5k
Description
Laravel Version
12.21.0
PHP Version
8.4.8
Database Driver & Version
MariaDB 10.5.26 for macOS (arm64) via Homebrew
Description
The php artisan db:table
command does not use the configured default database in config/database.php
or the DB_DATABASE
environment variable. Instead, it connects to the first database alphabetically available on the database server.
This causes the command to inspect tables from the wrong database when multiple databases exist on the same server.
Expected Behavior:
The command should use the database specified in DB_DATABASE
environment variable or the default connection configured in config/database.php
.
Actual Behavior:
The command connects to the first database alphabetically, ignoring the Laravel database configuration.
Workaround:
You can make it work but you have to specify your full database name each time: php artisan db:table my-laravel-app.users
Steps To Reproduce
- Set up a database server (MySQL/MariaDB) with multiple databases
- Ensure one database name comes alphabetically before your Laravel app database (e.g.,
chirper
and
my-laravel-app
) - Configure your Laravel app to use the latter database via
DB_DATABASE=my-laravel-app
in.env
- Run
php artisan db:table users
- Observe that it shows the table from the alphabetically first database (
chirper
) instead of the configured
database (my-laravel-app
)