psql: FATAL: role “postgres” does not exist
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!
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.
/Applications/Postgres.app/Contents/Versions/9.*/bin/createuser -s postgres
最新文章
- SQL中部分语法整理
- web iis服务器安全性配置实例
- angular 自定义指令 link
- CodeForces 483C Diverse Permutation
- HTTP协议的chunked编码
- HDU 3333-Turing Tree(BIT好题)
- 程序模拟浏览器请求及会话保持-python实现
- 画画 保存为图片 MaskFilter 边缘效果
- github使用入门 之GIT GUI Windows版
- tomcat7 https 成功测试
- 2014在百度之星资格赛的第二个问题Disk Schedule
- 用批处理文件自动备份文件及文件夹,并自动删除n天前的文件
- DirectFB 之 字体显示
- 编写shell脚本kill掉占用cpu超过90%以上的程序
- UTC,BJT时间的换算
- oracle instantclient_11_2 配置文件tnsnames.ora
- 要继续看Python写算法的内容请到那里去
- 几种线程安全的Map解析
- 使用pyinotify实现加强版的linux tail -f 命令,并且对日志类型的文本进行单独优化着色显示。
- Python dict转化为string方法
热门文章
- IOS Runtime属性关联实现表格编辑文本
- StatusStrip控件
- NFS挂载时出现";access denied by server while mounting";的解决方法
- [转] SQL函数说明大全
- jquery 获取 tagName(JQuery如何得到tagName?)
- 利用PHP的debug_backtrace函数,实现PHP文件权限管理、动态加载
- c#之泛型详解(Generic)
- IIS利用X-Forwarded-For获得来访者的真实IP
- easyui 带参数的datagride
- 1、类、封装(私有private、this关键字)