PostgreSQL初始化了与11.14不兼容的版本12



我在OSX 10.12、Rails 6.0.4、gem 'pg', '>= 0.18', '< 2.0'上并且最近注意到各种应用程序上的postgresql存在问题,这些问题已经冻结了一段时间。

Github/Le Wagon的rails模板甚至无法迁移:

rails db:migrate
rails aborted!
PG::ConnectionBad: could not connect to server: Connection refused
Is the server running on host "localhost" (::1) and accepting
TCP/IP connections on port 5432?

所以我做

postgres -D /usr/local/var/postgres
2021-12-04 15:14:57.335 CET [1964] FATAL:  database files are incompatible with server
2021-12-04 15:14:57.335 CET [1964] DETAIL:  The data directory was initialized by PostgreSQL version 12, which is not compatible with this version 11.14.

我刚刚做了一个升级,最后它说:

Warning: postgresql@12 12.9_1 is already installed and up-to-date.
To reinstall 12.9_1, run:
brew reinstall postgresql@12
➜  background-jobs-demo git:(master) ✗ postgres -V
postgres (PostgreSQL) 11.14

根据@AdrianKlaver的评论,我还发现了一个包含postgresql@11以及postgresql@12

最好的做法是什么?升级版本12?brew postgresql-upgrade-database会保证我升级版本12,而不是13或14吗?

我进行了正规化,但出现了问题,无法完成。感谢@AdrianKlaver的评论(问题是存在不同的postgresql版本(和链接:同时运行多个pstgresql并安装自制程序commons包。

  1. 检查并卸载当前的postgresql:
  2. 安装自制程序commons和postgres版本
  3. 创建服务器端但是服务器无法启动

出了什么问题?

1.    
brew list |grep postgr
brew uninstall postgresql@11
brew uninstall postgresql@12
2.
brew install petere/postgresql/postgresql-common
brew install petere/postgresql/postgresql@12
3.
pg_createcluster 12 main
pg_ctlcluster 12 main start

Error: /usr/local/opt/postgresql@12/bin/pg_ctl /usr/local/opt/postgresql@12/bin/pg_ctl start -D /usr/local/var/lib/postgresql/12/main -l /usr/local/var/log/postgresql/postgresql-12-main.log -s -o  -c config_file="/usr/local/etc/postgresql/12/main/postgresql.conf" -c external_pid_file="/usr/local/var/run/postgresql/12-main.pid"  exited with status 1: 
2021-12-04 22:44:50.632 CET [76694] LOG:  starting PostgreSQL 12.9 (Homebrew petere/postgresql) on x86_64-apple-darwin16.7.0, compiled by Apple LLVM version 9.0.0 (clang-900.0.39.2), 64-bit
2021-12-04 22:44:50.636 CET [76694] LOG:  listening on IPv6 address "::1", port 5432
2021-12-04 22:44:50.636 CET [76694] LOG:  listening on IPv4 address "127.0.0.1", port 5432
2021-12-04 22:44:50.638 CET [76694] LOG:  listening on Unix socket "/tmp/.s.PGSQL.5432"
2021-12-04 22:44:50.651 CET [76694] FATAL:  postmaster became multithreaded during startup
2021-12-04 22:44:50.651 CET [76694] HINT:  Set the LC_ALL environment variable to a valid locale.
2021-12-04 22:44:50.652 CET [76694] LOG:  database system is shut down
pg_ctl: could not start server
Examine the log output.

最新更新