How to specify a different locale for postgreSQL installation?

My system's locale is en_US.UTF-8. Because of that, the postgreSQL installation uses this locale by default for the cluster during installation.

Creating new cluster 9.3/main ... config /etc/postgresql/9.3/main data /var/lib/postgresql/9.3/main locale en_US.UTF-8 port 5432

But I want my postgreSQL server to install with locale pt_BR.UTF-8. Is it possible?

2 Answers

I just found a solution for this problem! Here it is..

1- Stop and drop your current cluster:

$ sudo pg_dropcluster --stop 9.3 main

2- Create a new cluster with the correct locale:

$ sudo locale-gen pt_BR.UTF-8
$ sudo pg_createcluster --locale pt_BR.UTF-8 9.3 main

3- Confirm it worked as expected:

$ sudo -u postgres psql
(9.3)
=> show LC_COLLATE;

Simply install it using below commands :

sudo apt-get update
sudo apt-get install postgresql postgresql-contrib

and then change the datastorage location :

/etc/postgresql/<VERSION>/main/postgresql.conf

eg : vi /etc/postgresql/8.4/main/postgresql.conf

Search for "data_directory" and provide your new datapath, now save the file and restart the postgresSQL service to reflect this new change.

Considered : your new path is /Database/Storage

Make sure, datapath is accessible only by postgres user - command to do that.

chown postgres.postgres /Database/Storage chmod 700 /Database/Storage

Hopes this helps,

1

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like