database - 用户 "postgres"的密码验证失败

标签 database postgresql

<分区>

我已经成功地在我的 CentOS 服务器上安装了 PostgreSQL server 8.4。 之后,我使用'postgres'用户登录到CentOS服务器,但我无法运行任何命令,出现错误:

password authentication failed for user "postgres"

这里是 pg_hba.conf 和 postgresql.conf 中的一些配置:

--------------------configuration in postgresql.conf-----------
listen_addresses = '*'

--------------------configuration in pg_hba.conf---------------
local   all         all                               md5  
local   all         postgres                          md5 
host    all         all         127.0.0.1/32          md5  
host    all         all         ::1/128               md5

最佳答案

我倾向于在 pg_hba.conf 中使用以下内容:

# Database administrative login by UNIX sockets
local   all         postgres                          ident

# TYPE  DATABASE    USER        CIDR-ADDRESS          METHOD
local   all         all                               md5
host    all         all         127.0.0.1/32          md5
host    all         all         ::1/128               md5

这意味着一旦你成为“postgres”,你就不需要密码,但你需要 sudo 权限才能成为 postgres,所以这是非常安全的。任何其他用户都可以使用简单的 md5 身份验证登录,这意味着您不必到处都使用 sudo。这对我来说效果很好。

关于database - 用户 "postgres"的密码验证失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7038342/

相关文章:

php - 从 $wpdb 获取正确的值

php - 将时间戳类型与 pg_prepare 一起使用

python - 在 psycopg2 中将表名作为参数传递

postgresql - Postgres : unable to create function

postgresql - 如何在 Vapor 3/Fluent 中记录 SQL 语句?

sql - 用于聚合数据的物化 View 与触发器?

mysql - 如何处理多个用户可能相同的用户输入数据

sql - postgresql 中奇怪的间隔

database - 备份 Wordpress 多站点

sql - 字段列表中的未知列 X