安装后无法连接到Mac OS X上的Postgresql

jas*_*328 7 sockets postgresql macos installation

所以我将Postgresql安装到我的Mac上,每当我运行任何类似的东西时psql,createdb cool_database_name我都会收到以下错误.

psql: could not connect to server: No such file or directory
    Is the server running locally and accepting
    connections on Unix domain socket "/tmp/.s.PGSQL.5432"?
Run Code Online (Sandbox Code Playgroud)

所以我遵循不同的解决方案.我重新安装postgresql无济于事.我去postgresql.conf`并将其更改为

#port = 5432                             # (change requires restart)
#max_connections = 20                    # (change requires restart)
# Note:  Increasing max_connections costs ~400 bytes of shared memory per
# connection slot, plus lock space (see max_locks_per_transaction).
#superuser_reserved_connections = 3     # (change requires restart)
#unix_socket_directory = '/var/pgsql_socket'             # (change requires restart)
#unix_socket_group = ''                 # (change requires restart)
#unix_socket_permissions = 0777         # begin with 0 to use octal notation
Run Code Online (Sandbox Code Playgroud)

但仍然没有.我运行的命令如

ls -lA /var/run/postgresql
Run Code Online (Sandbox Code Playgroud)

哪个告诉我文件或目录不存在.

我也检查了pg_hba.conf文件,但一切都很好

# "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
# Allow replication connections from localhost, by a user with the
# replication privilege.
#local   replication     jason                                trust
#host    replication     jason        127.0.0.1/32            trust
#host    replication     jason        ::1/128                 trust
Run Code Online (Sandbox Code Playgroud)

当我跑步时,psql -h localhost我得到了

psql: could not connect to server: Connection refused
    Is the server running on host "localhost" (::1) and accepting
    TCP/IP connections on port 5432?
could not connect to server: Connection refused
    Is the server running on host "localhost" (127.0.0.1) and accepting
    TCP/IP connections on port 5432?
could not connect to server: Connection refused
    Is the server running on host "localhost" (fe80::1) and accepting
    TCP/IP connections on port 5432?
Run Code Online (Sandbox Code Playgroud)

我迷失了如何解决这个问题.任何帮助,将不胜感激.

mys*_*mys 13

问题是Mac OS附带了PostgreSQL

$ `which psql` --version
psql (PostgreSQL) 9.1.4
contains support for command-line editing
Run Code Online (Sandbox Code Playgroud)

你需要像这样改变PATH:

export PATH="path_to_bin_folder_of_your_new_postgres_install:$PATH"
Run Code Online (Sandbox Code Playgroud)

例如,对于Postgres.app:

export PATH="/Applications/Postgres.app/Contents/MacOS/bin:$PATH"
Run Code Online (Sandbox Code Playgroud)

这可能很有用:http://blog.ringerc.id.au/2012/09/postgresql-packaging-on-mac-os-x-is-mess.html