Postgresql не может подключиться к серверу? - PullRequest
1 голос
/ 24 сентября 2019

Я новичок в postgresql и рельсах.Я пытаюсь подключиться к серверу и создать необходимые базы данных.Когда я запускаю rake db:create, я получаю это сообщение:

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"?
Couldn't create 'ecom_shoppie_development' database. Please check your configuration.
rake aborted!
PG::ConnectionBad: 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"?

Однако сервер работает на порту 5433. Я попытался изменить номер порта в postgresql.conf и database.yml, но я получаю ту же ошибку.

Я пытался удалить и переустановить postgresql, но он всегда выбирает порт 5433 вместо 5432.

Я следовал этому учебнику .

Postgresqlфайл журнала /var/log/postgresql/postgresql-11-main.log:

2019-09-24 06:12:09.951 EDT [3379] LOG:  listening on IPv4 address "127.0.0.1", port 5433
2019-09-24 06:12:10.087 EDT [3379] LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5433"
2019-09-24 06:12:10.669 EDT [3380] LOG:  database system was shut down at 2019-09-24 05:54:16 EDT
2019-09-24 06:12:11.313 EDT [3379] LOG:  database system is ready to accept connections
2019-09-24 06:12:12.102 EDT [3387] [unknown]@[unknown] LOG:  incomplete startup packet
2019-09-24 06:35:51.836 EDT [3379] LOG:  received fast shutdown request
2019-09-24 06:35:51.887 EDT [3379] LOG:  aborting any active transactions
2019-09-24 06:35:52.001 EDT [3379] LOG:  background worker "logical replication launcher" (PID 3386) exited with exit code 1
2019-09-24 06:35:52.003 EDT [3381] LOG:  shutting down
2019-09-24 06:35:52.842 EDT [3379] LOG:  database system is shut down
2019-09-24 06:35:54.193 EDT [3475] LOG:  could not bind IPv4 address "127.0.0.1": Permission denied
2019-09-24 06:35:54.193 EDT [3475] HINT:  Is another postmaster already running on port 5432? If not, wait a few seconds and retry.
2019-09-24 06:35:54.194 EDT [3475] WARNING:  could not create listen socket for "localhost"
2019-09-24 06:35:54.194 EDT [3475] FATAL:  could not create any TCP/IP sockets
2019-09-24 06:35:54.215 EDT [3475] LOG:  database system is shut down
pg_ctl: could not start server
Examine the log output.
2019-09-24 06:36:57.130 EDT [3517] LOG:  could not bind IPv4 address "127.0.0.1": Permission denied
2019-09-24 06:36:57.130 EDT [3517] HINT:  Is another postmaster already running on port 5432? If not, wait a few seconds and retry.
2019-09-24 06:36:57.130 EDT [3517] WARNING:  could not create listen socket for "localhost"
2019-09-24 06:36:57.131 EDT [3517] FATAL:  could not create any TCP/IP sockets
2019-09-24 06:36:57.153 EDT [3517] LOG:  database system is shut down
pg_ctl: could not start server
Examine the log output.
2019-09-24 06:38:02.555 EDT [3533] LOG:  could not bind IPv4 address "127.0.0.1": Permission denied
2019-09-24 06:38:02.555 EDT [3533] HINT:  Is another postmaster already running on port 5432? If not, wait a few seconds and retry.
2019-09-24 06:38:02.556 EDT [3533] WARNING:  could not create listen socket for "localhost"
2019-09-24 06:38:02.557 EDT [3533] FATAL:  could not create any TCP/IP sockets
2019-09-24 06:38:02.579 EDT [3533] LOG:  database system is shut down
pg_ctl: could not start server
Examine the log output.
2019-09-24 06:42:48.723 EDT [3564] LOG:  could not bind IPv4 address "127.0.0.1": Permission denied
2019-09-24 06:42:48.723 EDT [3564] HINT:  Is another postmaster already running on port 5432? If not, wait a few seconds and retry.
2019-09-24 06:42:48.724 EDT [3564] WARNING:  could not create listen socket for "localhost"
2019-09-24 06:42:48.724 EDT [3564] FATAL:  could not create any TCP/IP sockets
2019-09-24 06:42:48.746 EDT [3564] LOG:  database system is shut down
pg_ctl: could not start server
Examine the log output.
2019-09-24 06:44:22.342 EDT [3599] LOG:  listening on IPv4 address "127.0.0.1", port 5433
2019-09-24 06:44:22.463 EDT [3599] LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5433"
2019-09-24 06:44:23.036 EDT [3600] LOG:  database system was shut down at 2019-09-24 06:35:52 EDT
2019-09-24 06:44:23.772 EDT [3599] LOG:  database system is ready to accept connections
2019-09-24 06:44:24.488 EDT [3607] [unknown]@[unknown] LOG:  incomplete startup packet
2019-09-24 06:49:23.812 EDT [3601] WARNING:  could not flush dirty data: Function not implemented
2019-09-24 08:43:17.387 EDT [3599] LOG:  received fast shutdown request
2019-09-24 08:43:17.446 EDT [3599] LOG:  aborting any active transactions
2019-09-24 08:43:17.693 EDT [3599] LOG:  background worker "logical replication launcher" (PID 3606) exited with exit code 1
2019-09-24 08:43:17.695 EDT [3601] LOG:  shutting down
2019-09-24 08:43:18.620 EDT [3599] LOG:  database system is shut down
2019-09-24 08:43:20.185 EDT [6822] LOG:  could not bind IPv4 address "127.0.0.1": Permission denied
2019-09-24 08:43:20.185 EDT [6822] HINT:  Is another postmaster already running on port 5432? If not, wait a few seconds and retry.
2019-09-24 08:43:20.186 EDT [6822] WARNING:  could not create listen socket for "localhost"
2019-09-24 08:43:20.186 EDT [6822] FATAL:  could not create any TCP/IP sockets
2019-09-24 08:43:20.206 EDT [6822] LOG:  database system is shut down
pg_ctl: could not start server
Examine the log output.
2019-09-24 08:44:24.969 EDT [6857] LOG:  could not bind IPv4 address "0.0.0.0": Address already in use
2019-09-24 08:44:24.969 EDT [6857] HINT:  Is another postmaster already running on port 5432? If not, wait a few seconds and retry.
2019-09-24 08:44:24.969 EDT [6857] LOG:  could not bind IPv6 address "::": Address already in use
2019-09-24 08:44:24.969 EDT [6857] HINT:  Is another postmaster already running on port 5432? If not, wait a few seconds and retry.
2019-09-24 08:44:24.969 EDT [6857] WARNING:  could not create listen socket for "*"
2019-09-24 08:44:24.970 EDT [6857] FATAL:  could not create any TCP/IP sockets
2019-09-24 08:44:24.991 EDT [6857] LOG:  database system is shut down
pg_ctl: could not start server
Examine the log output.
2019-09-24 08:48:02.243 EDT [6894] LOG:  listening on IPv4 address "127.0.0.1", port 5433
2019-09-24 08:48:02.396 EDT [6894] LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5433"
2019-09-24 08:48:03.677 EDT [6895] LOG:  database system was shut down at 2019-09-24 08:43:17 EDT
2019-09-24 08:48:04.398 EDT [6894] LOG:  database system is ready to accept connections
2019-09-24 08:48:05.177 EDT [6902] [unknown]@[unknown] LOG:  incomplete startup packet
2019-09-24 08:53:04.168 EDT [6896] WARNING:  could not flush dirty data: Function not implemented
2019-09-24 15:10:39.731 EDT [7350] tjgrevious@tjgrevious FATAL:  password authentication failed for user "tjgrevious"
2019-09-24 15:10:39.731 EDT [7350] tjgrevious@tjgrevious DETAIL:  Password does not match for user "tjgrevious".
        Connection matched pg_hba.conf line 92: "host    all             all             127.0.0.1/32            md5"
2019-09-24 15:10:39.926 EDT [7351] tjgrevious@tjgrevious FATAL:  password authentication failed for user "tjgrevious"
2019-09-24 15:10:39.926 EDT [7351] tjgrevious@tjgrevious DETAIL:  Password does not match for user "tjgrevious".
        Connection matched pg_hba.conf line 92: "host    all             all             127.0.0.1/32            md5"
2019-09-24 15:10:53.402 EDT [7355] tjgrevious@tjgrevious FATAL:  database "tjgrevious" does not exist
2019-09-24 15:11:06.360 EDT [7358] tjgrevious@tjgrevious FATAL:  password authentication failed for user "tjgrevious"
2019-09-24 15:11:06.360 EDT [7358] tjgrevious@tjgrevious DETAIL:  Password does not match for user "tjgrevious".
        Connection matched pg_hba.conf line 92: "host    all             all             127.0.0.1/32            md5"
2019-09-24 15:11:06.478 EDT [7359] tjgrevious@tjgrevious FATAL:  password authentication failed for user "tjgrevious"
2019-09-24 15:11:06.478 EDT [7359] tjgrevious@tjgrevious DETAIL:  Password does not match for user "tjgrevious".
        Connection matched pg_hba.conf line 92: "host    all             all             127.0.0.1/32            md5"
2019-09-24 15:11:40.716 EDT [7374] tjgrevious@tjgrevious FATAL:  password authentication failed for user "tjgrevious"
2019-09-24 15:11:40.716 EDT [7374] tjgrevious@tjgrevious DETAIL:  Password does not match for user "tjgrevious".
        Connection matched pg_hba.conf line 92: "host    all             all             127.0.0.1/32            md5"
2019-09-24 15:11:40.853 EDT [7375] tjgrevious@tjgrevious FATAL:  password authentication failed for user "tjgrevious"
2019-09-24 15:11:40.853 EDT [7375] tjgrevious@tjgrevious DETAIL:  Password does not match for user "tjgrevious".
        Connection matched pg_hba.conf line 92: "host    all             all             127.0.0.1/32            md5"
2019-09-24 15:12:02.098 EDT [7378] tjgrevious@tjgrevious FATAL:  database "tjgrevious" does not exist

1 Ответ

0 голосов
/ 24 сентября 2019

Вы уверены, что он работает на 5433?Вы можете увидеть, что на самом деле работает, используя инструмент netstat (доступно в OS X, Windows и Linux, с синтаксисом командной строки, различающимся для всех трех)

Если вы на Mac и используетестандартная установка postgres, удалите ее и установите через homebrew.

В конечном итоге пользователь устанавливает Pg и запускает сервер из одной упаковки, но использует клиента psql и libpq из другой упаковки.Обычно это происходит, когда они запускают Postgres.app или homebrew Pg и соединяются с psql, поставляемым с ОС.Они не только иногда имеют разные порты по умолчанию, но и Pg, поставляемый с Mac OS X, имеет другой путь к сокету Unix по умолчанию, поэтому даже если сервер работает на том же порту, он не будет слушать тот же сокет Unix.

Большинство пользователей Mac могут обойти это, просто используя tcp / ip с psql -h localhost.При необходимости вы также можете указать порт, например, psql -h localhost -p 5433. Возможно, у вас запущено несколько экземпляров PostgreSQL, поэтому убедитесь, что вы подключаетесь к нужному, используя select version () и SHOW data_directory;.

Дальнейшие ответы на это можно найти postgresql порт путаница 5433 или 5432?

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...