ruby-on-rails - Postgresql无法连接到服务器?
问题描述
我是 postgresql 和 rails 的新手。我正在尝试连接到服务器并创建必要的数据库。当我运行时,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
解决方案
尝试这个:
$ rm /usr/local/var/postgres/postmaster.pid
$ brew services restart postgresql
推荐阅读
- javascript - Laravel 5.8 中带有 Vue 的选项卡
- python - 如何使用 Python-CAN 查看 CAN 网络的错误帧
- swift - 无法为 UIImageView 设置大小
- matplotlib - 如何使用 matplotlib 在两条直方图线之间进行颜色填充?
- firebase-hosting - 将 .well-known/assetlinks.json 上传到 Mac 上的 Firebase 托管
- delphi - 如何在 OleContainer 中将超链接添加到打开的 Word 文档中
- clojure - 使用 core.reducers 时的性能提升
- recursion - 递归拆解字符串时避免stackoverflow
- c++ - 类名类对象();不调用任何构造函数
- html - 如何只选择最后一个
在一个
?