Skip to content

Instantly share code, notes, and snippets.

@agguro
Forked from turboladen/psql_encoding.sql
Created October 24, 2018 14:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save agguro/99cd5e855fb271f22f099a9118b756a3 to your computer and use it in GitHub Desktop.
Save agguro/99cd5e855fb271f22f099a9118b756a3 to your computer and use it in GitHub Desktop.
Script for dealing with creating Postgres databases that complain with: ``` PG::InvalidParameterValue: ERROR: encoding UTF8 does not match locale en_US DETAIL: The chosen LC_CTYPE setting requires encoding LATIN1. ``` ...when trying to create the production DB. Taken from: http://stackoverflow.com/questions/13115692/encoding-utf8-does-not-match-…
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';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment