snippetsqlMinor
How to upgrade PostgreSQL from 9.5 to 9.6.1 without losing data?
Viewed 0 times
postgresqlwithoutlosinghowfromdataupgrade
Problem
When I tried to run
and when I checked
I tried to follow this tutorial (from 9.4 to 9.5) for upgrading 9.6.1, but keep getting this error message
after running
Does anyone have any idea what I am missing/doing wrong? Thanks!
System:
psql, I gotpsql: could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/tmp/.s.PGSQL.5432"?and when I checked
Server.log, I saw:FATAL: database files are incompatible with server
DETAIL: The data directory was initialized by PostgreSQL version 9.5,
which is not compatible with this version 9.6.1.I tried to follow this tutorial (from 9.4 to 9.5) for upgrading 9.6.1, but keep getting this error message
cannot write to log file pg_upgrade_internal.log
Failure, exitingafter running
$ pg_upgrade -v \
> -d /usr/local/var/postgres \
> -D /usr/local/var/postgres9.6.1 \
> -b /usr/local/Cellar/postgresql/9.5/bin/ \
> -B /usr/local/Cellar/postgresql/9.6.1/bin/Does anyone have any idea what I am missing/doing wrong? Thanks!
System:
- MacOS 10.12.2
- PostgreSQL installed with Homebrew
Solution
After 9 months, I updated to PostgreSQL 10 from 9.6.5 with
1) Stop postgresql:
2) Initialize postgresql10 database:
3) Double check the newly created db:
4) Run pq_upgrade to move data to new database:
5) Rename old database:
6) Rename new database to postgres:
7) Restart postgresql:
pg_upgrade:1) Stop postgresql:
brew services stop postgresql2) Initialize postgresql10 database:
initdb /usr/local/var/postgres10.0 -E utf83) Double check the newly created db:
ls /usr/local/Cellar/postgresql/4) Run pq_upgrade to move data to new database:
pg_upgrade \
-d /usr/local/var/postgres \
-D /usr/local/var/postgres10.0 \
-b /usr/local/Cellar/postgresql/9.6.5/bin/ \
-B /usr/local/Cellar/postgresql/10.0/bin/ \
-v5) Rename old database:
mv /usr/local/var/postgres /usr/local/var/postgres9.6.56) Rename new database to postgres:
mv /usr/local/var/postgres10.0 /usr/local/var/postgres7) Restart postgresql:
brew services start postgresqlCode Snippets
pg_upgrade \
-d /usr/local/var/postgres \
-D /usr/local/var/postgres10.0 \
-b /usr/local/Cellar/postgresql/9.6.5/bin/ \
-B /usr/local/Cellar/postgresql/10.0/bin/ \
-vContext
StackExchange Database Administrators Q#161129, answer score: 4
Revisions (0)
No revisions yet.