psql:致命:数据库“<用户>"不存在 [英] psql: FATAL: database "<user>" does not exist

查看:130
本文介绍了psql:致命:数据库“<用户>"不存在的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为Mac使用PostgreSql应用程序( http://postgresapp.com/).我过去在其他计算机上使用过它,但是在Macbook上安装时却给我带来了一些麻烦.我已经安装了应用程序,然后运行:

I'm using the PostgreSql app for mac (http://postgresapp.com/). I've used it in the past on other machines but it's giving me some trouble when installing on my macbook. I've installed the application and I ran:

psql -h localhost

它返回:

psql: FATAL:  database "<user>" does not exist

似乎我什至无法运行控制台来创建它要查找的数据库.当我刚运行时,会发生相同的事情:

It seems I can't even run the console to create the database that it's attempting to find. The same thing happens when I just run:

psql 

或者如果我从应用程序下拉菜单中启动psql:

or if I launch psql from the application drop down menu:

机器统计信息:

  • OSX 10.8.4

  • OSX 10.8.4

psql(PostgreSQL)9.2.4

psql (PostgreSQL) 9.2.4

感谢您的帮助.

我也尝试通过自制软件安装PostgreSql,但遇到了同样的问题.我还阅读了应用程序文档页面,其中指出:

I've also attempted to install PostgreSql via homebrew and I'm getting the same issue. I've also read the applications documentation page that states:

Postgres.app首次启动时,它将创建$ USER数据库, 如果未指定,则这是psql的默认数据库.这 默认用户为$ USER,没有密码.

When Postgres.app first starts up, it creates the $USER database, which is the default database for psql when none is specified. The default user is $USER, with no password.

看来应用程序没有在创建$ USER,但是我已经安装了-> uninstalled-reinstalled了好几次了,所以它一定是我的机器上的东西.

So it would seem the application is not creating $USER however I've installed->uninstalled-reinstalled several times now so it must be something with my machine.

我找到了答案,但是我不确定作为该线程的答案用户的工作方式-> 没有跟进.我使用以下命令来打开psql:

I found the answer but I'm not sure exactly how it works as the user who answered on this thread -> Getting Postgresql Running In Mac: Database "postgres" does not exist didn't follow up. I used the following command to get psql to open:

psql -d template1

我将不回答这个问题,直到有人可以解释为什么它起作用为止.

推荐答案

您的软件包管理器似乎无法为您创建名为$ user的数据库.原因

It appears that your package manager failed to create the database named $user for you. The reason that

psql -d template1

为您工作的原因是template1是由postgres本身创建的数据库,并且存在于所有安装中. 您显然可以登录template1,因此您必须具有数据库分配的某些权限.在shell提示下尝试以下操作:

works for you is that template1 is a database created by postgres itself, and is present on all installations. You are apparently able to log in to template1, so you must have some rights assigned to you by the database. Try this at a shell prompt:

createdb

,然后查看是否可以使用

and then see if you can log in again with

psql -h localhost

这只会为您的登录用户创建一个数据库,我想这就是您要寻找的数据库.如果createdb失败,则您没有足够的权限创建自己的数据库,因此您必须弄清楚如何修复自制程序包.

This will simply create a database for your login user, which I think is what you are looking for. If createdb fails, then you don't have enough rights to make your own database, and you will have to figure out how to fix the homebrew package.

这篇关于psql:致命:数据库“&lt;用户&gt;"不存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆