Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

I am using PostgreSQL 9.1. Trying to enforce UTF8 encoding as default.

This is what I am doing.

service postgresql initdb -E 'UTF-8' \
               --lc-collate='en_US.UTF-8' \
               --lc-ctype=locale='en_US.UTF-8';

Although the initilization process goes on without any problem,

a \l at the psql prompt gives there details.

                             List of databases
   Name    | Owner    |Encoding  | Collate | Ctype |   Access privileges   
-----------+----------+----------+---------+-------+-----------------------
 postgres  | postgres | LATIN1   | en_US   | en_US | 

Why is the UTF-8 encoding not getting enforced?

share|improve this question
    
The documentation[initdb] specifies -E as a shorthand. So the commend is legal. –  ThinkingMonkey Aug 5 '12 at 8:12
    
Sorry, I overlooked the -E. What happens if you call initdb directly? –  a_horse_with_no_name Aug 5 '12 at 8:17
    
@a_horse_with_no_name Apparently, if initdb is run through a runlevel script of the OS. This script might not pass on the parameters. I couldn't run initdb directly as a superuser. gave an initdb: cannot be run as root Please log in (using, e.g., "su") as the (unprivileged) user that will own the server process. error. After logging in as an unprivileged user I was able to initialize the db with the proper encoding. –  ThinkingMonkey Aug 5 '12 at 8:40
add comment

1 Answer 1

up vote 1 down vote accepted

If initdb is run through a run-level script of the OS. This script might not pass on the parameters.

I couldn't run initdb directly as a superuser. Gave an

initdb: cannot be run as root
Please log in (using, e.g., "su") as the (unprivileged) user that will
own the server process.

error. After logging in as an unprivileged user I was able to initialize the db with the proper encoding.

To initilize the db, run initdb directly. The command

/usr/bin/initdb --pgdata=/var/lib/pgsql9/data/ -E 'UTF-8' \
--lc-collate='en_US.UTF-8' \
--lc-ctype='en_US.UTF-8';

was run under the non-superuser postgres.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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