Creating a UTF-8 database in PostgreSQL

February 6, 2015   

I always forget the proper incantation for creating UTF-8 databases in PostgreSQL. I just had to do this for a project so I’m writing it down for future reference. Maybe it’ll be useful to somebody else out there.

<code>sudo -u postgres createdb -E UTF8 -T template0 --locale=en_US.utf8 template_utf8</code>

Now use this UTF-8 “template database” when creating your project database:

<code>createdb -T template_utf8 new_database</code>