我在 AWS linux 2 上设置弹性 beanstalk 时遇到问题。它是一个 laravel 应用程序,以 Postgres 作为数据库。用户密码验证失败
I'm having a problem with an elastic bean stalk setup on AWS linux 2. It's a laravel App with Postgres as the DB. Password auth failed for user
我在 AWS 上的弹性 beantalk 上有一个 laravel 应用程序。我正在使用 Postgres 作为数据库。这是一个 AWS linux 2.
当我尝试将本地连接到数据库时出现此错误。
我试过修改数据库的入站规则,还是不行。
Illuminate\Database\QueryException: SQLSTATE[08006] [7] FATAL:
password authentication failed for user "postgres" FATAL: password
authentication failed for user "postgres" (SQL: select count(*) as
aggregate from "user" where "phoneNumber" = +1111111111111111) in file
/var/app/current/vendor/laravel/framework/src/Illuminate/Database/Connection.php
on line 692
如果您的数据库是 AWS RDS 上的托管 PostgreSQL
那么您可能需要重置 postgres
用户的密码。
To modify the master user password, follow these steps:
- Open the Amazon RDS console.
- Select Databases.
- Select the RDS DB instance, and then choose Modify.
Note: If you use Aurora, expand the cluster, and choose the instance that you want to modify. Then, choose Modify.
- Enter the master user password you want to use in the New Master Password field.
Note: The password change is asynchronous, and applies as soon as possible. This change ignores the Apply Immediately setting.
- Choose Continue, and then choose Modify DB Instance.
The Status field for your RDS DB instance on the RDS dashboard changes to resetting-master-credentials. When the modification is complete, the Status column changes to Available. You can also modify an RDS DB instance using the Amazon RDS API or the AWS Command Line Interface (AWS CLI).
如果您的数据库自行部署到 AWS EC2
实例
那么您可能希望启用 postgres
用户的基于密码的身份验证。默认情况下,新数据库实例禁用它。
- 找到
pg_hba.conf
文件
要在您的服务器上找到 pg_hba.conf 文件,您可以查看 PostgreSQL 配置目录。
例如:
find /etc/postgresql/ -name pg_hba.conf
- 然后在
${EDITOR}
中打开找到的文件
- 要允许对来自本地 192.168.0.0/24 网络的任何连接进行 md5 密码验证,请添加如下一行:
# TYPE DATABASE USER ADDRESS METHOD OPTIONS
host all all 192.0.0.0/24 md5
- 然后 restart PostgreSQL:
sudo pgctl restart
你是对的@Yasen,谢谢大佬。
更改密码有效
我之前想到过,但我一直在用相同的密码创建新的数据库实例,但一直失败。
无论如何,根本问题是密码在 laravel 中包含“#”和“#”,因此 php 表示注释;
因此,它以某种方式影响了验证过程。
我在 AWS 上的弹性 beantalk 上有一个 laravel 应用程序。我正在使用 Postgres 作为数据库。这是一个 AWS linux 2.
当我尝试将本地连接到数据库时出现此错误。
我试过修改数据库的入站规则,还是不行。
Illuminate\Database\QueryException: SQLSTATE[08006] [7] FATAL: password authentication failed for user "postgres" FATAL: password authentication failed for user "postgres" (SQL: select count(*) as aggregate from "user" where "phoneNumber" = +1111111111111111) in file /var/app/current/vendor/laravel/framework/src/Illuminate/Database/Connection.php on line 692
如果您的数据库是 AWS RDS 上的托管 PostgreSQL
那么您可能需要重置 postgres
用户的密码。
To modify the master user password, follow these steps:
- Open the Amazon RDS console.
- Select Databases.
- Select the RDS DB instance, and then choose Modify.
Note: If you use Aurora, expand the cluster, and choose the instance that you want to modify. Then, choose Modify.- Enter the master user password you want to use in the New Master Password field.
Note: The password change is asynchronous, and applies as soon as possible. This change ignores the Apply Immediately setting.- Choose Continue, and then choose Modify DB Instance.
The Status field for your RDS DB instance on the RDS dashboard changes to resetting-master-credentials. When the modification is complete, the Status column changes to Available. You can also modify an RDS DB instance using the Amazon RDS API or the AWS Command Line Interface (AWS CLI).
如果您的数据库自行部署到 AWS EC2
实例
那么您可能希望启用 postgres
用户的基于密码的身份验证。默认情况下,新数据库实例禁用它。
- 找到
pg_hba.conf
文件 要在您的服务器上找到 pg_hba.conf 文件,您可以查看 PostgreSQL 配置目录。 例如:
find /etc/postgresql/ -name pg_hba.conf
- 然后在
${EDITOR}
中打开找到的文件
- 要允许对来自本地 192.168.0.0/24 网络的任何连接进行 md5 密码验证,请添加如下一行:
# TYPE DATABASE USER ADDRESS METHOD OPTIONS
host all all 192.0.0.0/24 md5
- 然后 restart PostgreSQL:
sudo pgctl restart
你是对的@Yasen,谢谢大佬。
更改密码有效
我之前想到过,但我一直在用相同的密码创建新的数据库实例,但一直失败。
无论如何,根本问题是密码在 laravel 中包含“#”和“#”,因此 php 表示注释; 因此,它以某种方式影响了验证过程。