8

そのため、Postgresql を Mac にインストールしましたが、次のようなものを実行するたびにpsqlcreatedb 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"?

だから私はさまざまな解決策に従っています。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ますが、すべて問題ないようです

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

私が走るとき、私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?

私はこれを修正する方法について途方に暮れています。どんな助けでも大歓迎です。

4

1 に答える 1

13

問題は、Mac OS が PostgreSQL を出荷していることです。

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

次のように PATH を変更する必要があります。

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

于 2013-02-20T06:44:44.767 に答える