您的位置:首页 > 运维架构 > Linux

Linux下postgresql忘记密码,以其他用户登录,phpmyadmin默认不允许登录的问题解决

2010-08-04 09:45 906 查看
Postgres允许以linux其他用户在命令行登录的配置:

1.修改/usr/local/pgsql/data目录下的文件pg_hba.conf

local all all ident omicron

2.修改/usr/local/pgsql/data目录下的文件pg_ident.conf 添加

omicron root postgres

3. 重启postgres

执行 /etc/init.d/postgresql restart

4.访问数据库时使用以下命令:

/usr/local/pgsql/bin/psql mydb -U postgres

这里用的是psql的绝对路径,如果是用过系统自动安装的情况,直接psql也是可以的,这个就根据你的系统情况而定了。1,2步骤里的路径也是如此。

Postgres默认不允许phppgadmin登录的问题:

1.修改/var/lib/pgsql/data/pg_hba.conf文件,如下:

#IPV4 local connections

host all all 127.0.0.1/32 md5 ////改为md5认证

2.修改/var/www/html/phppgadmin/conf/config.inc.php

$conf['extra_login_security'] = false; ////改为false

3.执行以下命令,创建postgre用户

#su postgres

$createuser test

输入两次密码....

问你是否将此用户设置为serperuser?选择yes

用户创建成功.

$exit ////切换回root用户

#/etc/rc.d/init.d/postgresql restart ////重启postgre数据库

再次用test用户和密码登陆phppgadmin即可。

修改数据库服务器密码:

以postgres用户执行psql postgres

执行:
ALTER USER postgres WITH ENCRYPTED PASSWORD 'yourpassword'

效果:

-----------------------------------------------------------------------------------------------------------------

Welcome to psql
8.2.6, the PostgreSQL interactive terminal.

Type: /copyright for
distribution terms

/h for help with SQL commands

/? for help with psql
commands

/g or terminate with semicolon to execute query

/q to
quit

postgres=# ALTER USER postgres WITH ENCRYPTED
PASSWORD 'yourpassword';

ALTER ROLE

postgres=#

------------------------------------------------------------------------------------------------------------------

以上内容分别来自于以下地址:
http://hi.baidu.com/luna_kiss_moon/blog/item/f57ba70ec71c8eeb37d12226.html http://www.xxlinux.com/linux/article/development/database/20070919/9818.html http://www.hacms.com/html/2010/0308/34551.html
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: