Skip to content

Instantly share code, notes, and snippets.

@acsrujan
Last active December 10, 2015 10:05
Show Gist options
  • Save acsrujan/5eb6ae01fd29432684a9 to your computer and use it in GitHub Desktop.
Save acsrujan/5eb6ae01fd29432684a9 to your computer and use it in GitHub Desktop.
Installs postgres 9.3
sudo touch /etc/apt/sources.list.d/pgdg.list
echo "deb http://apt.postgresql.org/pub/repos/apt/ precise-pgdg main" | sudo tee -a /etc/apt/sources.list.d/pgdg.list
wget --quiet -O - http://apt.postgresql.org/pub/repos/apt/ACCC4CF8.asc | sudo apt-key add -
sudo apt-get update
sudo apt-get -y install postgresql-9.3 libpq-dev postgresql-contrib-9.3
sudo apt-get autoremove
sudo pg_dropcluster --stop 9.3 main
sudo pg_createcluster --start -e UTF-8 9.3 main
#Change username and password as desired. Username need not be put in quotes but password need to be.
#In case of any extensions, login to psql with psql -h <hostname> -d <database_name> -U <username> -P
#Enter Password:
#You can avoid entering password always, by maintaining .pgpass.
sudo -u postgres psql -c "create role <username> with PASSWORD '<password>' SUPERUSER CREATEDB LOGIN;"
sudo -u postgres psql -c 'grant all on schema public to <username>;'
sudo service postgresql start
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment