Showing posts with label postgresql. Show all posts
Showing posts with label postgresql. Show all posts

Create user in postgres

1. sudo -s -u postgres
2. psql
3. CREATE USER <nom_utilisateur>;
4. ALTER USER <nom_utilisateur> WITH ENCRYPTED PASSWORD 'mon_mot_de_passe';
4. \q
5. exit


ALTER Role ms2phadmin CREATEDB;

Backup & Restore PostgreSQL DB

-- Backup
pg_dump -h localhost -U name_of_user name_of_database > file

-- Restore
psql -U name_of_user -h localhost name_of_database < file

http://www.postgresql.org/docs/8.1/static/backup.html

-- lancer ton fichier depuis une ligne de commande linux
psql -h monserveur -f monfichiersql

Tao va xoa CSDL trong postgresql

---- Tao CSDL trong postgresql
1. sudo -s -u postgres
2. psql
3. CREATE DATABASE name_of_database WITH OWNER = name_of_user ENCODING = 'UTF8';
4. \q
5. exit

---- Delete CSDL trong postgresql
1. sudo -s -u postgres
2. psql
3. DROP DATABASE name_of_database;
4. \q
5. exit

-- Xem danh sach CSDL hien co
select d.datname as name from pg_catalog.pg_database d;

pg_restore

pg_restore -h hostname -d databasename -t ilpcover ms2phdb_ilpcover.backup -U username -O