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

Fatal: role h9uest does not exist

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


当前回答

我把它安装在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

其他回答

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

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

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

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

工作方法,

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

这对我来说很管用:

psql -h localhost -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