Installing PostgreSQL on Ubuntu with UTF-8 database template
source link: https://gist.github.com/oieduardorabelo/9061945
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
Installing PostgreSQL on Ubuntu with UTF-8 database template · GitHub
Instantly share code, notes, and snippets.
Para instalar a versão mais atualizada do PostgreSQL, adicione o Apt Repository oficial:
echo 'deb http://apt.postgresql.org/pub/repos/apt/ precise-pgdg main' | sudo tee /etc/apt/sources.list.d/pgdg.list
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
sudo apt-get update
Agora você tem disponível através do apt-get
os seguintes pacotes:
- postgresql-client-9.3 - client libraries and client binaries
- postgresql-9.3 - core database server
- postgresql-contrib-9.3 - additional supplied modules
- libpq-dev - libraries and headers for C language frontend development
- postgresql - server-dev-9.3 - libraries and headers for C language backend development
- pgadmin3 - pgAdmin III graphical administration utility
Vamos instalar os pacotes:
sudo apt-get install postgresql-9.3 libpq-dev
Para verificar se o PostgreSQL foi instalado corretamente, vamos acessar os databases:
sudo su - postgres
psql
\list
Com isso você vai visualizar uma lista dos databases padrões do PostgreSQL,
Por padrão, o encoding do PostgreSQL é o LATIN1, vamos muda-lo para UTF8
UPDATE pg_database SET datistemplate = FALSE WHERE datname = 'template1';
DROP DATABASE template1;
CREATE DATABASE template1 WITH TEMPLATE = template0 ENCODING='UNICODE' LC_COLLATE='en_US.UTF8' LC_CTYPE='en_US.UTF8';
UPDATE pg_database SET datistemplate = TRUE WHERE datname = 'template1';
UPDATE pg_database SET datallowconn = FALSE WHERE datname = 'template1';
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK