我使用的是Ubuntu20.04AWS实例,其中php7.4/NGINX和Laravel 8.4指向PostgreSQL EC2实例(无公共访问权限)。
当我尝试迁移(php artisan migrate)时,我得到以下错误:
Illuminate\Database\QueryException
could not find driver (SQL: select * from information_schema.tables where table_schema = xxxxx-db-prod and table_name = migrations and table_type = 'BASE TABLE')SO中的Similar questions是关于如何安装或启用PostgreSQL驱动器的。但我已经安装并启用了它。运行php -i,我得到的结果是:
pdo_pgsql
PDO Driver for PostgreSQL => enabled
PostgreSQL(libpq) Version => 12.2 (Ubuntu 12.2-4)
pgsql
PostgreSQL Support => enabled
PostgreSQL(libpq) Version => 12.2 (Ubuntu 12.2-4)
PostgreSQL(libpq) => PostgreSQL 12.2 (Ubuntu 12.2-4) on x86_64-pc-linux-gnu, compiled by gcc (Ubuntu 9.3.0-8ubuntu1) 9.3.0, 64-bit
Multibyte character support => enabled
SSL support => enabled
Active Persistent Links => 0
Active Links => 0
Directive => Local Value => Master Value
pgsql.allow_persistent => On => On
pgsql.auto_reset_persistent => Off => Off
pgsql.ignore_notice => Off => Off
pgsql.log_notice => Off => Off
pgsql.max_links => Unlimited => Unlimited
pgsql.max_persistent => Unlimited => Unlimited运行php -m,我得到的结果是:
...
pcntl
pcre
PDO
pdo_pgsql
pgsql
Phar
...我在同一个Ubuntu20.04 EC2实例中测试了相同的指向本地PostgreSQL实例的实例,它可以正常工作。这似乎不是Laravel的问题。似乎与RDS-PostgreSQL连接有关。
有没有人有任何关于这个问题的线索?
更新
我注意到问题的根源是DB_CONNECTION值。我忘记在.env文件中将mysql更改为pgsql:
DB_CONNECTION=pgsql发布于 2020-12-02 12:53:11
我遇到了完全相同的问题,在重新启动ec2实例后,一切都正常工作。
¯_(ツ)_/`
https://stackoverflow.com/questions/63994765
复制相似问题