Nic Lin's Blog


如何在 Mac 上升級 PostgreSQL 並遷移資料

今天寫 side project 時要啟動資料庫時遇到 postgres 版本問題

waiting for server to start....2019-03-02 12:45:08.851 EST [3310] FATAL:  database files are incompatible with server
2019-03-02 12:45:08.851 EST [3310] DETAIL:  The data directory was initialized by PostgreSQL version 10, which is not compatible with this version 11.2.
 stopped waiting
pg_ctl: could not start server
Examine the log output.


brew postgresql-upgrade-database


Error: /usr/local/var/postgres.old already exists!
Remove it if you want to upgrade data automatically.


rm -rf /usr/local/var/postgres.old

再跑一次 brew postgresql-upgrade-database 沒意外就會看到

==> Upgraded postgresql data from 10 to 11!
==> Your postgresql 10 data remains at /usr/local/var/postgres.old
==> Successfully started `postgresql` (label: homebrew.mxcl.postgresql)


comments powered by Disqus