我已经在我的Ubuntu karma box上安装了PostgreSQL和pgAdminIII。
我能够成功地使用pgAdminIII(即连接/登录),但是当我尝试在命令行(使用psql)上使用相同的用户名/pwd登录到服务器时,我得到错误:
psql: FATAL: Ident authentication failed for user "postgres"
现在有人知道如何解决这个问题吗?
我已经在我的Ubuntu karma box上安装了PostgreSQL和pgAdminIII。
我能够成功地使用pgAdminIII(即连接/登录),但是当我尝试在命令行(使用psql)上使用相同的用户名/pwd登录到服务器时,我得到错误:
psql: FATAL: Ident authentication failed for user "postgres"
现在有人知道如何解决这个问题吗?
当前回答
在我的情况下,解决方案是:(给关心的人) 登录postgres:
sudo -i -u postgres
psql
ALTER USER postgres WITH PASSWORD 'postgres'; # type your password here
问候
其他回答
在Ubuntu 12.04中为Rails开发设置PostgreSQL之后,我也遇到了同样的问题
我尝试了其他答案,但我所要做的就是:“config/database.yml”
development:
adapter: postgresql
encoding: unicode
database: (appname)_development
pool: 5
username: (username you granted appname database priviledges to)
password:
在pg_hba.conf中设置正确了吗?
参见https://ubuntu.com/server/docs/databases-postgresql如何做。
可以设置环境变量PGHOST=localhost:
$ psql -U db_user db_name
psql: FATAL: Peer authentication failed for user "db_user"
$ export PGHOST=localhost
$ psql -U db_user db_name
Password for user mfonline:
我花了更多的时间来解决这个我愿意承认的错误。
我认为pg_hba.conf中的身份验证配置顺序与您的情况相关。默认配置文件在普通安装中包含几行。这些默认值可以匹配身份验证尝试的条件,从而导致身份验证失败。不管在.conf文件末尾添加了什么额外的配置,它都会失败。
要检查使用的是哪一行配置,请确保查看消息的默认日志文件。你可能会看到这样的东西
LOG: could not connect to Ident server at address "127.0.0.1", port 113: Connection refused
FATAL: Ident authentication failed for user "acme"
DETAIL: Connection matched pg_hba.conf line 82: "host all all 127.0.0.1/32 ident"
结果是这条默认行导致了拒绝。
host all all 127.0.0.1/32 ident
试着把它注释掉。
以防以上方法都不适合你: 我已经安装了不少Postgres,但今天在RedHat 6.5系统上(安装Postgres 9.3)却被搞糊涂了。Aron在上面展示的典型hba.conf配置不起作用。原来我的系统使用的是IPV6,而忽略了IPV4配置。添加一行:
host all all ::1/128 password
允许我成功登录。