Change PostgreSQL Locale

wrote by Rafael Marangoni, from Suporte Linux team.

This article explains how to change the default PostgreSQL Locale. Be careful, because we're considering that you do not have data on the PostgreSQL instance.

First, we need to stop the Postgres service (if was not already stopped):

service postgresql stop

Then we need to remove all data files from PostgreSQL data-dir. On RedHat based, that's the dir:

rm -rf /var/lib/pgsql/data/*

Now we change to Postgres user:

su postgres

Creating the initial data, selecting the Locale:

initdb --locale=C /var/lib/pgsql/data

or

initdb --locale=pt_BR.UTF-8 /var/lib/pgsql/data

or your locale

service postgresql stop

Then, we start Postgres service:

service postgresql start

Leave a Comment