无法设置postgres用户密码

尝试在CentOS 6.5上使用Ruby on Rails和Nginx来安装PostgreSQL,使用以下指南: http : //karolgalanciak.com/blog/2013/07/19/centos-6-4-server-setup-with-ruby-on-轨-nginx的,和PostgreSQL的/

安装后我去configuration用户,所以发出命令sudo su postgres然后psql 。 当我这样做,我得到以下错误:

 could not change directory to "/root": Permission denied psql (9.3.4) 

忽略这个,我发布了命令:

 alter user postgres with password 'postgres-user-password'; 

然后我去auth方法更改为MD5镝做:

 sudo vi /var/lib/pgsql/9.3/data/pg_hba.conf 

当我这样做时,我会看到提示符:

 [sudo] password for postgres: 

不pipeinput什么密码,我都会告诉Sorry, try again. 即使密码正好是我刚刚设置的密码。

尝试按照user716468从这篇文章的指示,但没有运气: 新的安装后postgres的默认超级用户名/密码是什么?

当我做sudo -u postgres psql postgres我被告知:

 postgres is not in the sudoers file. This incident will be reported. You have new mail in /var/spool/mail/root 

这里有什么问题?

首先,当使用sudo的时候总是总是使用-l或者只是简单的。 例如,“ sudo su - postgres ”不是“ sudo su postgres ”。 这可以确保您正确地获取目标用户环境。

听起来就像你使用sudo作为root用户。 这是不必要的。 root用户已经拥有所需的权限。

如果你想要一个用户使用sudo,那么你需要在/ etc / sudoers中有一个合适的configuration项。 由于postgres accoutn是一个服务帐户,你最好不要为postgres创build一个sudoers条目。 最好只从事“正常”账户的工作。