Created
July 8, 2013 15:23
-
-
Save anandology/5949798 to your computer and use it in GitHub Desktop.
Fixing PostgreSQL default encoding in Ubuntu
This file contains 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
# Option 1 - rebuild the cluster | |
# This will delete alle existing data | |
pg_dropcluster --stop 9.2 main | |
pg_createcluster --start -e UTF-8 9.2 main | |
# Option 2 - rebuild the template1 database | |
# All the database created after this will have UTF-8 encoding | |
psql template1 -c "UPDATE pg_database SET datallowconn = TRUE WHERE datname='template0'" | |
psql template0 -c "UPDATE pg_database SET datistemplate = FALSE WHERE datname='template1'" | |
dropdb template1 | |
createdb template1 -T template0 -E utf-8 | |
psql template0 -c "UPDATE pg_database SET datistemplate = TRUE WHERE datname='template1'" | |
psql template1 -c "UPDATE pg_database SET datallowconn = FALSE WHERE datname='template0'" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment