我正在尝试开始使用 Laravel + PostgreSQL 并一直在关注数据库教程。
不幸的是,更新数据库配置文件并运行php artisan migrate
后,出现如下错误:
[InvalidArgumentException]
Database [postgres] not configured.
令我困惑的是,我没有在配置中指定“postgres”数据库,而是我通过cPanel设置的另一个数据库,说“example_database”。
/config/database.php
这是我的配置的一些相关部分:
'default' => env('DB_CONNECTION', 'postgres')
connections
在同一文件的数组中:
'pgsql' => [
'driver' => 'pgsql',
'host' => env('DB_HOST', 'localhost'),
'database' => env('DB_DATABASE', 'example_database'), // This seems to be ignored
'username' => env('DB_USERNAME', 'example_username'),
'password' => env('DB_PASSWORD', 'example_password'),
'charset' => 'utf8',
'prefix' => '',
'schema' => 'public'
],
我使用的实际数据库凭据在我的 SQL Workbench 客户端上运行良好,所以这似乎是 Laravel 配置问题。有任何想法吗?我已经搜索了至少一个小时无济于事。