After automatically updating Postgres to 10.0 via Homebrew, the pg_ctl start command didn't work. The error was "The data directory was initialized by PostgreSQL version 9.6, which is not compatible with this version 10.0."
Database files have to be updated before starting the server, here are the steps that had to be followed:
brew unlink postgresql brew install [email protected] brew unlink [email protected] brew link postgresql
mv /usr/local/var/postgres /usr/local/var/postgres96
initdb /usr/local/var/postgres -E utf8
mkdir /usr/local/share/postgresql96 cp -r /usr/local/share/postgresql/timezone /usr/local/share/postgresql96 cp -r /usr/local/share/postgresql/timezonesets /usr/local/share/postgresql96
pg_upgrade -b /usr/local/Cellar/[email protected]/9.6.5/bin -B /usr/local/Cellar/postgresql/10.0/bin -d /usr/local/var/postgres96 -D /usr/local/var/postgres
pg_ctl start -D /usr/local/var/postgres
brew uninstall [email protected] rm -rf /usr/local/var/postgres96 rm -rf /usr/local/share/postgresql96