2012-02-25 61 views
1

Postgresql不合作。我做了一大堆postgresql和postgresql-server,这似乎很好。我然后试着``,它给出和错误信息:postgresql提供权限问题

createdb: could not connect to database postgres: FATAL: Ident authentication failed for user "postgres"

如果我删除用户它只给我的用户名相同的错误。我在Centos操作系统上。我想在创建数据库之后使用apache和php。

当我运行/usr/bin/postgres它给出了一个错误:

/usr/bin/postgres does not know where to find the server configuration file. You must specify the --config-file or -D invocation option or set the PGDATA environment variable.

不能弄明白。我错过了配置步骤吗?我认为做百胜餐饮可以起到作用。

回答

1

听起来就像它被配置为用于身份认证,这就需要你登录作为Linux用户postgres的,即:

su postgres 

然后运行CREATEDB命令。其他的方法是找到你的pg_hba.conf,可能是/var/lib/pgsql/9.1/data,然后切换到信任认证。这样,您可以使用-U postgres与任何linux帐户进行连接,并且它会让您无需验证密码。然后,您可以设置所需的用户名和密码,然后切换到更安全的内容,如md5。

+0

因此,我编辑了pg_hba.conf以包含在文件末尾:'host all all 127.0.0.1/32 trust'。然后我尝试重新启动服务器,但它说'pg_ctl:没有指定数据库目录,环境变量PGDATA未设置' – user983223 2012-02-25 21:15:03

+0

你说的是成为postgres然后创建用户是正确的。我的问题是我没有想到我有一个名为postres的用户。我通过成为root然后成为postgres然后createuser创建我想要的用户来解决问题 – user983223 2012-02-25 21:31:36

+0

将下列内容添加到.profile或.bash_profile中以解决数据目录问题:export PGDATA =/Library/PostgreSQL/9.2/data/' – Tom 2013-06-05 01:25:10