Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save tonespy/8228f771912300732c41901b99dd0c97 to your computer and use it in GitHub Desktop.

Select an option

Save tonespy/8228f771912300732c41901b99dd0c97 to your computer and use it in GitHub Desktop.

Revisions

  1. @giannisp giannisp revised this gist Oct 18, 2017. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -3,7 +3,7 @@ The error was "The data directory was initialized by PostgreSQL version 9.6, whi

    Database files have to be updated before starting the server, here are the steps that had to be followed:

    # need to have both 9.6.x and latest 10.0 installed, and keep 9.6.x as default
    # need to have both 9.6.x and latest 10.0 installed, and keep 10.0 as default
    brew unlink postgresql
    brew install postgresql@9.6
    brew unlink postgresql@9.6
  2. @giannisp giannisp created this gist Oct 18, 2017.
    34 changes: 34 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,34 @@
    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:

    # need to have both 9.6.x and latest 10.0 installed, and keep 9.6.x as default
    brew unlink postgresql
    brew install postgresql@9.6
    brew unlink postgresql@9.6
    brew link postgresql

    # move 9.6.x db files to another directory
    mv /usr/local/var/postgres /usr/local/var/postgres96

    # init new database using 10.0
    initdb /usr/local/var/postgres -E utf8

    # make timezone and timezonesets directories available for 9.6.x installation
    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

    # finally the actual upgrade
    # -b is the old binary dir, -B is the new binary dir
    # -d is the old data dir, -D is the new data dir
    pg_upgrade -b /usr/local/Cellar/postgresql@9.6/9.6.5/bin -B /usr/local/Cellar/postgresql/10.0/bin -d /usr/local/var/postgres96 -D /usr/local/var/postgres

    # start 10.0 to check that upgrade works
    pg_ctl start -D /usr/local/var/postgres

    # cleanup if upgrade was successful
    brew uninstall postgresql@9.6
    rm -rf /usr/local/var/postgres96
    rm -rf /usr/local/share/postgresql96