I need it in order to create a new database with initdb with the same locale, otherwise pg_upgrade will fail.

2 Answers 2


One option is to use psql -l, but it outputs many lines if there a lot of databases.


When upgrading to postgresql 16 or later, this is no longer relevant. The locale and encoding match requirement has been removed as redundant, pg_upgrade now copies the encoding settings itself: https://github.com/postgres/postgres/commit/9637badd9f9209166140eb567602e91699dd2ffb

When upgrading to postgresql 15 or older, the most important are the locale settings for the database named template0.

psql -c '\l template0'

initdb should be called with same --encoding=... --locale=... --lc-collate=...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.