我是postgres的新手。

我安装了postgres。我在玩psql命令,我不小心掉了postgres数据库。我不知道里面有什么。

我目前正在制作一个教程:http://www.rosslaird.com/blog/building-a-project-with-mezzanine/

我被困在sudo -u postgres psql postgres

错误信息:psql: FATAL: role "postgres"不存在

$ which PSQL

/Applications/Postgres.app/Contents/MacOS/bin/psql

这是psql -l输出的内容

                                List of databases
    Name    |   Owner    | Encoding | Collate | Ctype |     Access privileges     
------------+------------+----------+---------+-------+---------------------------
 user       | user       | UTF8     | en_US   | en_US | 
 template0  | user       | UTF8     | en_US   | en_US | =c/user                  +
            |            |          |         |       | user      =CTc/user      
 template1  | user       | UTF8     | en_US   | en_US | =c/user                  +
            |            |          |         |       | user      =CTc/user      
(3 rows)

那么我应该采取哪些步骤呢?删除一切相关的psql和重新安装一切?

谢谢你们的帮助!


当前回答

这对我很有效

创建用户 -s postgres

注意:我用的是mac catalina

其他回答

如果你从brew安装了postgres,在你的终端上运行:

/usr/local/opt/postgres/bin/createuser -s postgres

这是唯一一个帮我解决问题的:

createuser -s -U $USER

为了它的价值,我有ubuntu和许多软件包安装,它去与它冲突。

对我来说,正确答案是:

sudo -i -u postgres-xc
psql
psql -U debug -d dashboard_3

我必须使用postgres:14 Docker容器的终端指定用户名和数据库名,以便能够将psql输入到数据库中。

这篇文章帮助我解决了psql: FATAL: role“postgres”不存在的问题。

我使用的是mac,所以我在终端输入了这个命令:

创建用户 -s postgres

这对我很有效。