Skip to content

Instantly share code, notes, and snippets.

@siumhossain
Forked from joshteng/psql_encoding.markdown
Created March 16, 2022 16:12
Show Gist options
  • Save siumhossain/efc1da95e540d36126cf7d908b13bf64 to your computer and use it in GitHub Desktop.
Save siumhossain/efc1da95e540d36126cf7d908b13bf64 to your computer and use it in GitHub Desktop.
This solves Postgresql's encoding issue (happened to me when running postgres on my vagrant box) The error happens when trying to create db "rake db:create": Error message: "encoding UTF8 does not match locale en_US; the chosen LC_CTYPE setting requires encoding LATIN1"
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';
\q
exit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment