【PostgreSQL】在启动服务器时出现错误
错误消息
ActiveRecord :: ConnectionNotEstablished
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"?
做過的事情 (zuò guò de shì
-
- PC自体を再起動 → NGだった
psql -Vを実行
バージョンがpsql (PostgreSQL) 14.1
brew services listを実行
postgresql が error
tail -n 20 /usr/local/var/log/postgres.logを実行
2022-02-04 05:55:21.403 JST [4050] FATAL: database files are incompatible with server
2022-02-04 05:55:21.403 JST [4050] DETAIL: The data directory was initialized by PostgreSQL version 13, which is not compatible with this version 14.1.
2022-02-04 05:55:31.536 JST [4118] FATAL: database files are incompatible with server
以下省略
:
:
:
解决方案 (jiě jué àn)
据推测,由于PostgreSQL的重大更新,导致数据库无法读取的情况。请依次执行以下操作。
brew services stop postgresql
==> Successfully stopped `postgresql`
brew upgrade postgresql
Warning: postgresql 14.1_1 already installed
rm -rf /usr/local/var/postgres.old
brew postgresql-upgrade-database
==> Upgrading postgresql data from 13 to 14...
省略
:
:
==> Upgraded postgresql data from 13 to 14!
==> Your postgresql 13 data remains at /usr/local/var/postgres.old
brew services start postgresql
==> Successfully started `postgresql`
brew services list
postgresql started
果然兼容性是个问题呢;;
总之可解决真是太好了ーー。