17 September 2010

PostgreSQL - Manual (silent) instalation

PostgreSQL - Manual (silent) instalation
1) Download postgresql-*.*.zip.
Here we’ll use c:\pgsql as the target directory, so
2) Extract the archive to that directory.
Go to that folder and type in command prompt
3) initdb c:\pgsql\data
4) pg_ctl register -N postgres -D c:\pgsql\data
5) net start postgres
net user postgres postgres /add /expires:never
6) createdb database_name
or
createdb -E unicode --template template0 database_name
7) createuser -d -s user_name (postgres)
8) psql -U user_name -d database_name -f file.backup
and then, if needed
or
pg_restore --host localhost --port 5432 --username postgres --dbname database_name --verbose file.sql
9) pg_ctl unregister -N postgres

Change database encoding to UTF-8

vacuumdb --full --analyze --username postgres --dbname MYDB
pg_dump MYDB -Ft -v -U postgres -f tmp/MYDB.tar
dropdb MYDB --username postgres
createdb --encoding UNICODE MYDB --username postgres
pg_restore tmp/MYDB.tar | psql --dbname MYDB --username postgres
vacuumdb --full --analyze --username postgres --dbname MYDB
Post a Comment