Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why did this postgres database upgrade fail?

Tags:

postgresql

I am trying to upgrade from Postgresql 9.6 to 10 unsuccessfully.

I ran brew upgrade postgresql with success, then ran brew postgresql-upgrade-database with failure message. The issue seems to be this line:

lc_collate values for database "postgres" do not match: old "en_GB.UTF-8", new "en_US.UTF-8"

The whole message was:

    ==> Upgrading postgresql data from 9.6 to 10...
Stopping `postgresql`... (might take a while)
==> Successfully stopped `postgresql` (label: homebrew.mxcl.postgresql)
==> Moving postgresql data from /usr/local/var/postgres to /usr/local/var/postgres.o
The files belonging to this database system will be owned by user "jbkimac".
This user must also own the server process.

The database cluster will be initialized with locale "en_US.UTF-8".
The default database encoding has accordingly been set to "UTF8".
The default text search configuration will be set to "english".

Data page checksums are disabled.

fixing permissions on existing directory /usr/local/var/postgres ... ok
creating subdirectories ... ok
selecting default max_connections ... 100
selecting default shared_buffers ... 128MB
selecting dynamic shared memory implementation ... posix
creating configuration files ... ok
running bootstrap script ... ok
performing post-bootstrap initialization ... ok
syncing data to disk ... ok

WARNING: enabling "trust" authentication for local connections
You can change this by editing pg_hba.conf or using the option -A, or
--auth-local and --auth-host, the next time you run initdb.

Success. You can now start the database server using:

    /usr/local/opt/postgresql/bin/pg_ctl -D /usr/local/var/postgres -l logfile start

Performing Consistency Checks
-----------------------------
Checking cluster versions                                   ok
Checking database user is the install user                  ok
Checking database connection settings                       ok
Checking for prepared transactions                          ok
Checking for reg* data types in user tables                 ok
Checking for contrib/isn with bigint-passing mismatch       ok
Checking for invalid "unknown" user columns                 ok
Creating dump of global objects                             ok
Creating dump of database schemas
                                                            ok

lc_collate values for database "postgres" do not match:  old "en_GB.UTF-8", new "en_US.UTF-8"
Failure, exiting
Error: Upgrading postgresql data from 9.6 to 10 failed!
==> Removing empty postgresql initdb database...
==> Moving postgresql data back from /usr/local/var/postgres.old to /usr/local/var/p
==> Successfully started `postgresql` (label: homebrew.mxcl.postgresql)
Error: Failure while executing; `/usr/local/opt/postgresql/bin/pg_upgrade -r -b /usr/local/Cellar/postgresql/9.6.1/bin -B /usr/local/opt/postgresql/bin -d /usr/local/var/postgres.old -D /usr/local/var/postgres -j 8` exited with 1.

Can anyone help advise me as to how to fix this "en_GB.UTF-8", new "en_US.UTF-8" conflict issue?

like image 702
jbk Avatar asked Sep 27 '18 14:09

jbk


People also ask

Can I upgrade from Postgres 11 to 13?

Installing PostgreSQL 13 can be done on the same host. First, you must make sure things such as the database port are unique. In other words, it has to be different from the current PostgreSQL 11 installed on the same host.


2 Answers

brew services stop postgresql
brew postgresql-upgrade-database
brew services start postgresql
like image 125
Kim Soly Avatar answered Sep 16 '22 15:09

Kim Soly


I had the same issue with brew postgresql-upgrade-database and had to change /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/cmd/brew-postgresql-upgrade-database.rb as @Thermatix mentioned. Both --lc-collate and --lc-ctype have to correspond with the current database settings. In my case ch_DE.UTF8 for both.

like image 38
Marc Widmer Avatar answered Sep 20 '22 15:09

Marc Widmer