postgres没有用户或角色,无法创建但可以与Rails一起使用吗? [英] postgres no users or roles, can't create but works with rails?
本文介绍了postgres没有用户或角色,无法创建但可以与Rails一起使用吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试在OSX上设置postgres。我在使用Rails应用程序时遇到问题(无法连接到数据库),并使用自制软件重新安装了postgres。我现在不能从终端发出postgres命令:
I'm trying to setup postgres on OSX. I was having problems with a rails app ('cannot connect to database') and reinstalled postgres with homebrew. I cannot issue postgres commands from terminal now though:
$ sudo -u _postgres psql
Password:
psql: FATAL: role "_postgres" does not exist
$ brew list
autoconf libksba openssl python sqlite
automake libtool ossp-uuid rbenv
gdbm libyaml pkg-config readline
libgpg-error mongodb postgresql ruby-build
$ postgresql
zsh: command not found: postgresql
$ psql
psql: FATAL: database "connorleech" does not exist
此命令确实有效:
$ sudo -u _postgres
usage: sudo -h | -K | -k | -L | -V
usage: sudo -v [-AknS] [-g groupname|#gid] [-p prompt] [-u user name|#uid]
usage: sudo -l[l] [-AknS] [-g groupname|#gid] [-p prompt] [-U user name] [-u
user name|#uid] [-g groupname|#gid] [command]
usage: sudo [-AbEHknPS] [-C fd] [-g groupname|#gid] [-p prompt] [-u user
name|#uid] [-g groupname|#gid] [VAR=value] [-i|-s] [<command>]
usage: sudo -e [-AknS] [-C fd] [-g groupname|#gid] [-p prompt] [-u user
name|#uid] file ...
在我用homebrew重新安装了postgresql后,我的rails应用程序开始使用此 app / config / database.yml
:
After I reinstalled postgresql with homebrew my rails app began working with this app/config/database.yml
:
development:
adapter: postgresql
encoding: utf8
host: localhost
database: project_development
pool: 5
username:
password:
问题:
- 如何从终端发出
postgres
命令? - 如果我从未创建本地
postgres
用户或数据库,rails将如何运行应用程序?
- How do I issue
postgres
commands from the terminal? - How is rails running an app if I never created a local
postgres
user or database?
推荐答案
如果您从此处安装了postgres 对于Mac OSX,请尝试以下操作:
If you installed postgres from here for Mac OSX try this:
- 从bash psql的根目录开始
- 这将以应用程序创建的用户身份登录(在我的情况下,这是我的Mac用户名,例如 jamesbrown)。
- 您将看到类似jamesbrown =#的提示。 ..输入 \du
- 现在您将看到所有角色,如果要添加超级用户,我的角色包括jamesbrown和_postgres
- 到_postgres,更改用户_postgres超级用户;
- From root in bash "psql"
- This will log on in as the user that the app created (in my case this was my mac user name e.g. "jamesbrown")
- you'll be at a prompt like jamesbrown=#... enter "\du"
- you'll now see all the roles, mine included jamesbrown and _postgres
- if you want to add superuser to _postgres, "alter user _postgres superuser;"
这篇关于postgres没有用户或角色,无法创建但可以与Rails一起使用吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文