Skip to content

Instantly share code, notes, and snippets.

@filipechagas
Created August 22, 2014 19:48
Show Gist options
  • Save filipechagas/eae4f633b864287f68c0 to your computer and use it in GitHub Desktop.
Save filipechagas/eae4f633b864287f68c0 to your computer and use it in GitHub Desktop.
Postgres Rails - UTF-8 Problem
source: http://stackoverflow.com/questions/13115692/encoding-utf8-does-not-match-locale-en-us-the-chosen-lc-ctype-setting-requires
I am answering this because nothing from StackOverFlow worked for me.
I combined two solutions from other sites that did the job (this answer works for Ubuntu server 12.04 and PGSQL 9.1):
Create a file:
nano /etc/profile.d/lang.sh
Add the following
export LANGUAGE="en_US.UTF-8"
export LANG="en_US.UTF-8"
export LC_ALL="en_US.UTF-8"
Save it
Restart shell or run all export commands manually in current shell instance
Reconfigure so the encoding can be UTF8 ([got it from here][1])
sudo su postgres
psql
update pg_database set datistemplate=false where datname='template1';
drop database Template1;
create database template1 with owner=postgres encoding='UTF-8'
lc_collate='en_US.utf8' lc_ctype='en_US.utf8' template template0;
update pg_database set datistemplate=true where datname='template1';
Use template1 for db creation.
I hope this helps ;)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment