PostgreSQL+phpPgAdmin总是登录失败login failed

我的配置步骤:

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 allident]搞的鬼,如果是ident的话需要配置pg_ident.conf文件,所以果断换成除以上两种加密方式外的方法

重启postgresql:#service postgresql restart.

再访问一次,成功。

相关文章

项目需要,有个数据需要导入,拿到手一开始以为是mysql,结果...
本文小编为大家详细介绍“怎么查看PostgreSQL数据库中所有表...
错误现象问题原因这是在远程连接时pg_hba.conf文件没有配置正...
因本地资源有限,在公共测试环境搭建了PGsql环境,从数据库本...
wamp 环境 这个提示就是说你的版本低于10了。 先打印ph...
psycopg2.OperationalError: SSL SYSCALL error: EOF detect...