最近将我的机器从 Mac OS X Lion (10.7.4) 更新到 Mountain Lion (10.8),我认为它破坏了我的 PostgreSQL 安装。它最初是通过 Homebrew 安装的。我不是 DBA,但希望有人能告诉我如何解决这个问题。
我无法连接(但在前 Mountain Lion 之前能够连接):
$ psql -U rails -d myapp_development
psql: could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/var/pgsql_socket/.s.PGSQL.5432"?
Run Code Online (Sandbox Code Playgroud)
但是 Postgres 显然还在运行:
$ ps aux | grep postgres
meltemi 2010 0.0 0.0 2444124 5292 ?? Ss Wed01PM 0:00.02 postgres: rails myapp_development [local] idle
meltemi 562 0.0 0.0 2439312 592 ?? …Run Code Online (Sandbox Code Playgroud) 我对在 PostgreSQL 中设置权限有点困惑。
我有这些角色:
List of roles
Role name | Attributes | Member of
-----------+------------------------------------------------+-----------
admin | Superuser, Create role, Create DB, Replication | {}
meltemi | Create role, Create DB | {rails}
rails | Create DB, Cannot login | {}
myapp | | {rails}
Run Code Online (Sandbox Code Playgroud)
和数据库:
List of databases
Name | Owner | Encoding | Collate | Ctype | Access privileges
---------------------+--------+----------+-------------+-------------+-------------------
myapp_production | rails | UTF8 | en_US.UTF-8 | en_US.UTF-8 |
...
Run Code Online (Sandbox Code Playgroud)
用户myapp在查询myapp_production数据库添加和删除记录时没有问题。我希望meltemi也能够查询相同的数据库。所以,我创建了一个角色 …
我在某些服务器上运行了2 个PostgreSQL实例。一个默认端口(5432)和端口5433.有些用户(和工艺)只需要进入二审(5433)其他实例上,我想设置它,这样,当这些用户使用的命令状psql或createdb在他们的 shell 中,它会自动将他们引导到正确的 Postgres 实例,而不是他们必须-p 5433随着每个命令一起输入。
我试图在 www.postgresql.org 上查找它,但找不到它……可能是我的错。有谁知道怎么做?
我对 MySQL 和 MongoDB(都在服务器上运行良好)有一些(尽管有限)的经验,但在使用 Postgres 时遇到了问题,并且发现文档对于像我这样的新手来说缺乏。
Postgres 已安装并正在运行。但我无法从客户端连接。
pg_hba.conf 看起来像这样(我添加了最后一行):
# TYPE DATABASE USER CIDR-ADDRESS METHOD
# "local" is for Unix domain socket connections only
local all all trust
# IPv4 local connections:
host all all 127.0.0.1/32 trust
# IPv6 local connections:
host all all ::1/128 trust
## Added by me
host all all 10.0.1.201/32 trust
Run Code Online (Sandbox Code Playgroud)
现在,如果我去客户端10.0.1.201并尝试psql -h server.domain.com我得到一个错误:
psql: could not connect to server: Connection refused
Is the server running on host "server.domain.com" (10.0.1.38) and …Run Code Online (Sandbox Code Playgroud)