PostgreSQL+phpPgAdmin总是登录失败(login failed)

来源:互联网 发布:双色球大赢家缩水软件 编辑:程序博客网 时间:2024/06/06 08:58

我的配置步骤:

postgresql-8.4.11.tar.gz

phpPgAdmin-5.1.tar.bz2

1、解压到服务器apache所在的DocumentRoot的目录下(具体的目录可以通过phpinfo来查找,我的是在DOCUMENT_ROOT->  /var/www/html)

cd /var/www/html/

#tar jxvf phpPgAdmin-5.1.tar.bz2

#mv phpPgAdmin-5.1 phpPgAdmin

#cd /phpPgAdmin/conf

#sudo gedit config.inc.php

把$conf['extra_login_security'] = false;修改为$conf['extra_login_security'] = true;

 

网上所谓的修改postgresql.conf中的”tcpip_socket = true“在我所安装的版本中没有这一配置。

然后输入http://127.0.0.1/phpPgAdmin可以看到期望已久的画面了。

然后用postgres和之前已经设置好的密码(我的123456)登录,但是还是登不上去,老出现登录失败(login failed)的消息。

这里添上修改postgres用户密码的方法:

[root@localhost ~]# su postgres
bash-4.1$ psql
could not change directory to "/root"
psql (8.4.18)
Type "help" for help.

postgres=# alter user postgres password '123456';
ALTER ROLE
postgres=# \q
bash-4.1$ exit

登录失败的解决方法:

1.确认phpPgAdmin是否可以链接到postgresql数据库,方法:查看data/pg_log下的log有没有phpPgAdmin的访问记录,有则说明可以链接。

   以下为出错信息:

   LOG:  provided username (postgres) and authenticated username (apache) don't match
   FATAL:  Ident authentication failed for user "postgres"

 

2.查看postgresql的认证方法:pg_hba.conf

# "local" is for Unix domain socket connections only
local   all         all                               ident
# IPv4 local connections:
host    all         all         127.0.0.1/32          md5
# IPv6 local connections:
host    all         all         ::1/128               md5

以上看着貌似配置也合理,但是就是访问不上,最后在postgresql论坛上找到一个帖子:http://postgresql.1045698.n5.nabble.com/pg-ident-conf-not-working-td3215467.html

看着好像跟ident认证方式有点关系,最后在官方文档找到一句话:

When using an external authentication system like Ident or GSSAPI, the name of the operating system user that initiated the connection might not be the same as the database user he needs to connect as.

明白了,原来上面的[local   all         all          ident]搞的鬼,如果是ident的话需要配置 pg_ident.conf文件,所以果断换成除以上两种加密方式外的方法

重启postgresql:#service postgresql restart.

再访问一次,成功。

0 0
原创粉丝点击