当升级Postgres时遇到了错误

事件的根源


 $ postgres -D /usr/local/var/postgres
dyld: Library not loaded: /usr/local/opt/icu4c/lib/libicui18n.63.dylib
  Referenced from: /usr/local/bin/postgres
  Reason: image not found
zsh: abort      postgres -D /usr/local/var/postgres

无法启动。

因此 cǐ)


$ brew upgrade postgresql

完成了。

再次尝试启动


 $ postgres -D /usr/local/var/postgres
waiting for server to start....2020-04-10 10:54:23.161 JST FATAL:  database files are incompatible with server
2020-04-10 10:54:23.161 JST DETAIL:  The data directory was initialized by PostgreSQL version 11, which is not compatible with this version 12.2.
 stopped waiting
pg_ctl: could not start server
Examine the log output.

哦,原来如此。版本不对,是吗?
请确认一下有没有写任何说明,或者检查一下升级时的回应。


$ brew upgrade postgresql

中略


To migrate existing data from a previous major version of PostgreSQL run:
  brew postgresql-upgrade-database

To have launchd start postgresql now and restart at login:
  brew services start postgresql
Or, if you don't want/need a background service you can just run:
  pg_ctl -D /usr/local/var/postgres start

要从以前的主要版本的PostgreSQL迁移现有数据,请运行以下命令:
brew postgresql-upgrade-database

就是这个。。 ..)

试一试。

$ brew postgresql-upgrade-database

中略

Upgrade Complete
----------------
Optimizer statistics are not transferred by pg_upgrade so,
once you start the new server, consider running:
    ./analyze_new_cluster.sh

Running this script will delete the old cluster's data files:
    ./delete_old_cluster.sh
==> Upgraded postgresql data from 11 to 12!
==> Your postgresql 11 data remains at /usr/local/var/postgres.old

有人仔细地教授如何处理旧数据。

一切平安无事可以启动了。??


 $ postgres -D /usr/local/var/postgres
bannerAds