Skip to content

Instantly share code, notes, and snippets.

Last active December 10, 2015 10:05
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Installs postgres 9.3
sudo touch /etc/apt/sources.list.d/pgdg.list
echo "deb precise-pgdg main" | sudo tee -a /etc/apt/sources.list.d/pgdg.list
wget --quiet -O - | 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