Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to update a postgresql database with brew?

I wonder if this command is enough to update my PostgreSQL database installed with Homebrew, or if I need to run some extra commands before or after:

brew postgresql-upgrade-database

Thanks in advance.

I haven't tried it yet, before doing it I want to be sure it is the appropriate command

like image 561
Daniel N. Avatar asked Sep 01 '25 15:09

Daniel N.


1 Answers

Decided to just use pg_upgrade directly:

  • Moved the unversioned data to be the v14 data: mv /usr/local/var/postgres /usr/local/var/postgresql@14
  • Installed postgresql@16 alongside postgresql@14: brew install postgresql@16
  • Used pg_upgrade by running: /usr/local/opt/postgresql@16/bin/pg_upgrade -b /usr/local/opt/postgresql@14/bin -B /usr/local/opt/postgresql@16/bin -d /usr/local/var/postgresql@14 -D /usr/local/var/postgresql@16
  • Uninstalled postgresql@14: brew uninstall postgresql@14
  • Linked postgresql@16

For Apple Silicon Chip (M series), here is the right path

  • Moved the un-versioned data to be the v14 data (if the folder is not labelled postgresql@14 already): mv /usr/local/var/postgres /usr/local/var/postgresql@14
  • Installed postgresql@16 alongside postgresql@14: brew install postgresql@16
  • Used pg_upgrade by running: /opt/homebrew/Cellar/postgresql@16/16.3/bin/pg_upgrade -b /opt/homebrew/Cellar/postgresql@14/14.12/bin -B /opt/homebrew/Cellar/postgresql@16/16.3/bin -d /opt/homebrew/var/postgresql@14 -D /opt/homebrew/var/postgresql@16
  • Uninstalled postgresql@14: brew uninstall postgresql@14
  • Linked postgresql@16
like image 161
kheengz Avatar answered Sep 04 '25 06:09

kheengz