I'm a postgres novice.

I installed the postgres.app for mac. I was playing around with the psql commands and I accidentally dropped the postgres database. I don't know what was in it.

I'm currently working on a tutorial: http://www.rosslaird.com/blog/building-a-project-with-mezzanine/

And I'm stuck at sudo -u postgres psql postgres

ERROR MESSAGE: psql: FATAL: role "postgres" does not exist

$ which psql

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

This is what prints out of 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)

So what are the steps I should take? Delete an everything related to psql and reinstall everything?

Thanks for the help guys!

 linux配置

 
up vote242down voteaccepted

Note that the error message does NOT talk about a missing database, it talks about a missing role. Later in the login process it might also stumble over the missing database.

But the first step is to check the missing role: What is the output within psql of the command \du ? On my Ubuntu system the relevant line looks like this:

                              List of roles
Role name | Attributes | Member of
-----------+-----------------------------------+-----------
postgres | Superuser, Create role, Create DB | {}

If there is not at least one role with superuser, then you have a problem :-)

If there is one, you can use that to login. And looking at the output of your \l command: The permissions for user on the template0 and template1 databases are the same as on my Ubuntu system for the superuser postgres. So I think your setup simple uses user as the superuser. So you could try this command to login:

sudo -u user psql user

If user is really the DB superuser you can create another DB superuser and a private, empty database for him:

CREATE USER postgres SUPERUSER;
CREATE DATABASE postgres WITH OWNER postgres;

But since your postgres.app setup does not seem to do this, you also should not. Simple adapt the tutorial.

answered Mar 9 '13 at 10:13
A.H.

window配置
/Applications/Postgres.app/Contents/Versions/9.*/bin/createuser -s postgres
 

psql: FATAL: role “postgres” does not exist的更多相关文章

  1. psql: FATAL: role “postgres” does not exist 解决方案

    当时想做的事情,是运行一个创建数据库的脚本.找到的解决方案差不多和下面这个链接相同. http://stackoverflow.com/questions/15301826/psql-fatal-ro ...

  2. 配置recovery_min_apply_delay后重启standby节点报错:psql: FATAL: the database system is starting up

    环境: pg版本:PostgreSQL 9.4.4 on x86_64 系统版本:CentOS release 6.6 linux内核版本:2.6.32-504.8.1.el6.x86_64 今天测试 ...

  3. 备库搭建后,进入备库报错psql: FATAL: the database system is starting up

        备库搭建后,进入备库报错psql: FATAL:  the database system is starting up  原因:备库配置文件没有hot_standby = on   mast ...

  4. postgresql 使用pg_restore时显示role "root" does not exist的解决办法

    在docker里恢复bakcup格式的数据库,结果提示role "root" does not exist 解决方法: 切换用户: su - postgres 然后再次运行命令: ...

  5. psql: 致命错误: 用户 "postgres" Ident 认证失败

    RedHat: 问题: psql -U postgres 时出现:psql: 致命错误:  用户 "postgres" Ident 认证失败 解决: 修改 /var/lib/pgs ...

  6. ORA-01919: role 'PLUSTRACE' does not exist

    环境:Oracle 10g,11g. 现象:在一次迁移测试中,发现有这样的角色赋权会报错不存在: SYS@orcl> grant PLUSTRACE to jingyu; grant PLUST ...

  7. ORA-01917: user or role 'PDB_DBA' does not exist

    在使用seed PDB创建新的PDB的时候,报了以下错误提示: SQL> create pluggable database pdb2 admin user admin1 identified ...

  8. ORA-01919: role 'OLAPI_TRACE_USER' does not exist

    我在用数据泵导入数据的时候报的错 TEST_USER1@ORCL> conn / as sysdbaSYS@ORCL> grant plustrace to TEST_USER1; gra ...

  9. 诊断:ORA-01919: role ‘PLUSTRACE’ does not exist

    如下错误 SQL> grant plustrace to scott; grant plustrace to scott * ERROR at line 1: ORA-01919: role ' ...

随机推荐

  1. pygame(一)

    昨天,是有在树莓派上面操作pygame的,但是树莓派又上不了网了,很奇怪,我的306wifi显示的是树莓派连接成功,但是就是无法用网络,所以就下载不了图片,坐等HDMI线吧. 现在,看小甲鱼的视频已经 ...

  2. window常用的快捷键

    1.win+r打开运行命令 2.appwiz.cpl打开程序面板,进行程序的安装.卸载 输入win+r打开运行命令,输入appwiz.cpl 3.services.msc打开服务,一般用于启动或者关闭 ...

  3. 关于C# 委托(delegate)与事件(event)的用法及事例

    C#中的委托和事件对于新手可能会有一点难理解,所以先从一个小例子入手,以便能更好的理解其如何使用.有一个学生每天定闹钟在早上6点起床,所以当每天早上6点的时候,闹钟就会响起来,从而学生才会按时起床. ...

  4. java语言的各种输入情况(ACM常用)

    1.只输入一组数据: Scanner s=new Scanner(System.in); int a=s.nextInt(); int b=s.nextInt(); 2.输入有多组数据,没有说明输入几 ...

  5. js-script标签放在的位置

    * 建议把script标签放到</body>后面 * 如果现在有这样一个需求 在js里面需要获取到input里面的值,如果把script标签放到head里面,会出现问题.HTML解析是从上 ...

  6. UOJ42. 【清华集训2014】Sum

    传送门 Sol \((-1)^a=1-2(a~mod~2)=1-2a+4\lfloor\frac{a}{2}\rfloor\) 那么原式变成 \(n-2\sum_{i=1}^{n}\lfloor d\ ...

  7. 解决Cannot read property 'style' of null中样式问题

    <script type="text/javascript"> function updateTime(){ var timeNow = new Date(); var ...

  8. 关于 Table 表格那些三两事儿

    引言 实现下列表格样式,嵌套与form表单中提交信息,为了让自己的表格可以“ 随心所欲 ” 变换自己的形式,需要两个重要的td 属性colspan 列合并 以及 rowspan 行合并 来实现,表格宽 ...

  9. 远景平台开发者上线,专业API免费使用

    远景平台开发者上线,欢迎大伙围观使用. 在开发者中心你可以做什么? 1.管理你的应用,通过APPKEY获取在线API.使用云中的数据和地图. 2.学习API的使用,包含API参考和部分例子(目前例子很 ...

  10. 出售基于Html5的高性能GIS平台源码

    远景地理信息系统平台软件 远景地理信息系统平台软件,简称"RemoteGIS",版本V1.0,它是基于HTML5自主研发的新一代WEBGIS平台,它使用Javascript开发,具 ...