简体   繁体   English

Laravel 迁移未连接 AWS-RDS postgres(找不到驱动程序...)。 PDO 已经安装。 如何解决?

[英]Laravel migrations is not connecting AWS-RDS postgres (could not find driver ...). PDO already installed. How to solve that?

I am using an Ubuntu 20.04 EC2 instance with php7.4/NGINX and Laravel 8.4 point to a PostgreSQL RDS instance (no public access) in AWS.我正在使用 Ubuntu 20.04 EC2 实例和 php7.4/NGINX,Laravel 8.4 指向 AWS 中的 PostgreSQL RDS 实例(无公共访问权限)。

When I try to migrate ( php artisan migrate ) I am getting the following error:当我尝试迁移 ( 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')

Similar questions in SO is point in how to install or enable the PostgreSQL drive. SO 中的类似问题指向如何安装或启用 PostgreSQL 驱动器。 But I have already it installed and enabled.但是我已经安装并启用了它。 Running php -i this is what I get:运行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

Running php -m this is what I get:运行php -m这就是我得到的:

...

pcntl
pcre
PDO
pdo_pgsql
pgsql
Phar
...

I have tested the same instance point to a local PostgreSQL instance, inside the same Ubuntu 20.04 EC2 instance and it works.我已经在同一个 Ubuntu 20.04 EC2 实例中测试了指向本地 PostgreSQL 实例的相同实例点,它可以正常工作。 It seems that this is not a Laravel issue.看来这不是 Laravel 的问题。 Seems to be something related to the RDS-PostgreSQL connection.似乎与 RDS-PostgreSQL 连接有关。

Does someone have any clue related to this issue?有人对这个问题有任何线索吗?

Update更新


I notice that the origin of the issue was the DB_CONNECTION value.我注意到问题的根源是DB_CONNECTION值。 I forgot to change mysql to pgsql in the .env file:我忘记在.env文件中将mysql更改为pgsql

DB_CONNECTION=pgsql

I had exactly the same problem, after restarting the ec2 instance everything worked.我遇到了完全相同的问题,在重新启动 ec2 实例后一切正常。

¯_(ツ)_/¯ ¯_(ツ)_/¯

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM