Tag Archives: postgresql

Postgresql: export/import users with privileges

It's easy to transfer users from one instance to anothe:
#dump users and permissions
sudo -u postgres pg_dumpall -g > globals_only.dump
#restore them
cat globals_only.dump | sudo -u postgres psql
# or if you would like to choose specific user
grep USERNAME globals_only.dump

1
2
3
CREATE ROLE "USERNAME";
ALTER ROLE "USERNAME" WITH NOSUPERUSER INHERIT NOCREATEROLE NOCREATEDB LOGIN NOREPLICATION PASSWORD 'md56933b22c7ea06924799dbac5d7ed8072';
GRANT ro TO "USERNAME" GRANTED BY postgres;

These commands you could input directly to postgres command-line.

Postgresql 9.2 for Ubuntu 12.04 and 10.04

Add repository: http://www.postgresql.org/download/linux/ubuntu/

1
2
3
echo deb http://apt.postgresql.org/pub/repos/apt/ precise-pgdg main | sudo tee /etc/apt/sources.list.d/postgresql.list
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
sudo apt-get update

setup postgres:

1
sudo apt-get install postgresql-9.2 postgresql-contrib-9.2