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

Fatal: role h9uest does not exist

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


当前回答

Windows用户:psql -U postgres

然后你应该看到PostgreSQL的命令行界面: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

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

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.

对于使用docker并正确遵循官方文档说明的用户,如果仍然遇到此问题,请重新启动窗口并重试。

使用apt-get安装postgres不会创建用户角色或数据库。

创建超级用户角色和个人用户帐户数据库:

Sudo -u postgres createuser -s $(whoami);createdb whoami(美元)

对于Postgres 9.5版本,使用以下命令:

psql -h localhost -U postgres

希望这能有所帮助。