Last active
December 21, 2015 06:39
-
-
Save plusplus/6265438 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
vagrant@precise64:/vagrant/prereqs-rhel-v3$ sudo -u postgres createdb -O postgres -E utf8 -T template0 dbname | |
createdb: database creation failed: ERROR: encoding UTF8 does not match locale en_US | |
DETAIL: The chosen LC_CTYPE setting requires encoding LATIN1. | |
vagrant@precise64:/vagrant/prereqs-rhel-v3$ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
postgres=# \list | |
List of databases | |
Name | Owner | Encoding | Collate | Ctype | Access privileges | |
-----------+----------+----------+------------+------------+----------------------- | |
postgres | postgres | LATIN1 | en_US | en_US | | |
template0 | postgres | LATIN1 | en_US | en_US | =c/postgres + | |
| | | | | postgres=CTc/postgres | |
template1 | postgres | UTF8 | en_US.utf8 | en_US.utf8 | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
echo "UPDATE default encoding for new databases" | |
(cat <<'EOF' | |
update pg_database set datistemplate = FALSE where datname = 'template1'; | |
drop database template1; | |
create database template1 with ENCODING = 'UTF-8' LC_CTYPE = 'en_US.utf8' LC_COLLATE = 'en_US.utf8' template = template0; | |
update pg_database set datistemplate = TRUE where datname = 'template1'; | |
EOF | |
) > /tmp/fix_encoding.sql | |
sudo -u postgres psql -f /tmp/fix_encoding.sql |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment