2013-02-20 16 views
6

私はMacにPostgreSQLをインストールしました。psqlcreatedb cool_database_nameのようなものを実行すると、次のエラーが発生します。インストール後にMac OS XでPostgreSQLに接続できませんでした

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"? 

したがって、私はさまざまな解決策に従っています。 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 

に変更します。

ls -lA /var/run/postgresql 

などのコマンドを実行すると、ファイルやディレクトリが存在しないことがわかります。

私もpg_hba.confファイルにチェックしますが、すべては私が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? 

を取得

# "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 

OKに見えます。どんな助けもありがとう。

答えて

13

問題は、Mac OSの船が

$ `which psql` --version 
psql (PostgreSQL) 9.1.4 
contains support for command-line editing 

あなたはこのようなパスを変更する必要があるPostgreSQLのことです:

export PATH="path_to_bin_folder_of_your_new_postgres_install:$PATH" 

例えば、Postgres.appのために:

export PATH="/Applications/Postgres.app/Contents/MacOS/bin:$PATH" 

これはあるかもしれません有用:http://blog.ringerc.id.au/2012/09/postgresql-packaging-on-mac-os-x-is-mess.html

+0

あなたは天才です。ありがとう! – jason328

+0

私の場合、パスは '/ Applications/Postgres.app/Contents/Versions/9.4/bin'でした。 –

+0

.dmgからpostgresをインストールし、 '/Library/PostgreSQL/9.5/bin'を参照しなければなりませんでした。 – Kim

関連する問題