2013-02-20 12 views
6

Tak więc zainstalowałem PostgreSQL na moim Macu i kiedykolwiek uruchomię coś takiego jak psql lub createdb cool_database_name pojawia się następujący błąd.Nie można połączyć się z PostgreSQL na Mac OS X po instalacji

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

Więc śledzę różne rozwiązania. Ponownie instaluję PostgreSQL bez skutku. Przechodzę do postgresql.conf i zmieniam go na

#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 

ale wciąż nic. Uruchamiam polecenia, takie jak:

ls -lA /var/run/postgresql 

Co oznacza, że ​​plik lub katalog nie istnieje.

ja również sprawdzić w pliku pg_hba.conf ale wszystko wygląda ok

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

Kiedy biegnę psql -h localhost uzyskać

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? 

jestem na zagubioną, jak to naprawić. Każda pomoc będzie doceniona.

Odpowiedz

13

Problem polega na tym, że statki Mac OS PostgreSQL

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

Trzeba zmienić PATH tak:

export PATH="path_to_bin_folder_of_your_new_postgres_install:$PATH" 

przykład dla Postgres.app:

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

To może być użyteczne: http://blog.ringerc.id.au/2012/09/postgresql-packaging-on-mac-os-x-is-mess.html

+0

Jesteś geniuszem. Dzięki! – jason328

+0

Dla mnie ścieżką była '/ Applications/Postgres.app/Contents/Versions/9.4/bin' –

+0

Zainstalowałem postgres z pliku .dmg i musiałem odwołać się do" /Library/PostgreSQL/9.5/bin " – Kim

Powiązane problemy