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

Fatal: role h9uest does not exist

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


当前回答

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

其他回答

我用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

对我来说,像将端口从5432更改为5433这样简单的操作就可以了。

工作方法,

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

我把它安装在macOS上,必须:

cd /Applications/Postgres.app/Contents/Versions/9.5/bin
createuser -U postgres -s YOURUSERNAME
createdb YOURUSERNAME

来源如下:https://github.com/PostgresApp/PostgresApp/issues/313#issuecomment-192461641

sudo -u postgres createuser --superuser $USER

sudo -u postgres createdb $USER

这绝对适合你。