我正在设置PostgreSQL 9.1。我不能用PostgreSQL做任何事情:不能createdb,不能createuser;所有操作都返回错误消息

Fatal: role h9uest does not exist

h9uest是我的帐户名,我在这个帐户下执行apt-get安装PostgreSQL 9.1。 根帐户仍然存在类似的错误。


当前回答

在本地用户提示符,而不是根用户提示符中键入

sudo -u postgres createuser <local username>

输入本地用户密码。

然后输入前面的命令,生成“角色‘username’不存在”。

以上步骤为我解决了问题。 如果没有,请发送终端消息进行以上步骤。

其他回答

工作方法,

vi /etc/postgresql/9.3/main/pg_hba.conf 本地所有postgres peer 这里将peer改为trust 重启,sudo服务postgresql重启 现在试试,psql -U postgres

在尝试了许多其他人的解决方案后,都没有成功,这个答案最终帮助了我。

https://stackoverflow.com/a/16974197/2433309

简而言之,跑步

sudo -u postgres createuser owning_user

创建名为owning_user(在本例中为h9uest)的角色。在此之后,您可以在终端上运行rake db:create,使用您设置的任何帐户名,而无需进入Postgres环境。

遵循以下步骤,它将为你工作:

run msfconsole type db_console some information will be shown to you chose the information who tell you to make: db_connect user:pass@host:port.../database sorry I don't remember it but it's like this one then replace the user and the password and the host and the database with the information included in the database.yml in the emplacement: /usr/share/metasploit-framework/config you will see. rebuilding the model cache in the background. Type apt-get update && apt-get upgrade after the update restart the terminal and lunch msfconsole and it works you can check that by typing in msfconsole: msf>db_status you will see that it's connected.

这对我来说很管用:

psql -h localhost -U postgres

我用docker-compose做了健康检查。

healthcheck:
  test: ['CMD-SHELL', 'pg_isready']
  interval: 5s
  timeout: 5s
  retries: 5

如果你也有这样的更改用户:

healthcheck:
  test: ['CMD-SHELL', 'pg_isready -U postgres'] # <<<---
  interval: 5s
  timeout: 5s
  retries: 5