http://www.postgresql.org/download/linux/ubuntu/
- Install postgres
- create the file
/etc/apt/sources.list.d/pgdg.list
- add one of the following lines to the file based on ubuntu version:
- 14.04:
deb http://apt.postgresql.org/pub/repos/apt/ trusty-pgdg main
- 15.04:
deb http://apt.postgresql.org/pub/repos/apt/ wily-pgdg main
- 14.04:
- import signing key:
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | \ sudo apt-key add -
- update apt package lists:
sudo apt-get update
- Install:
sudo apt-get install postgresql-9.4
- create the file
- configure postgres
- become postgres superuser
sudo -u postgres i
- open psql (as postgres superuser):
psql
- create user role:
CREATE USER username AS SUPERUSER CREATEDB CREATEROLE REPLICATION;
- exit psql:
\q
- run
createdb username
to create a postgres database namedusername
- exit postgres user:
exit
- become postgres superuser
- allow clone access
- navigate to
/etc/postgresql/9.4/main/
- make backup of conf
cp pg_hba.conf pg_hba.conf.bak
- sudo edit
/etc/postgresql/9.4/main/pg_hba.conf
- near the bottom, add your user with
method
set totrust
:
# Database administrative login by Unix domain socket local all postgres peer local all username trust #add this line
- change the rest of the methods to
trust
# "local" is for Unix domain socket connections only local all all trust # IPv4 local connections: host all all 127.0.0.1/32 trust # IPv6 local connections: host all all ::1/128 trust
- save
pg_hba.conf
and exit - restart
- navigate to
- you should now be able to
pg_dump | pg_restore