Skip to content

Instantly share code, notes, and snippets.

@murilopontes
Last active August 22, 2016 20:56
Show Gist options
  • Save murilopontes/e23b87bad1c2b2bc658136f4ea00eee9 to your computer and use it in GitHub Desktop.
Save murilopontes/e23b87bad1c2b2bc658136f4ea00eee9 to your computer and use it in GitHub Desktop.
#!/bin/bash
#add repo
echo deb http://apt.postgresql.org/pub/repos/apt/ trusty-pgdg main > /etc/apt/sources.list.d/pgdg.list
#add key for repo
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
#get new list of packages
sudo apt-get update
#install
apt-get install postgresql-9.4
#apt-get install postgresql-9.5
#apt-get install postgresql-9.6
#change port to 5435 /etc/postgresql/9.4/main/postgresql.conf
#set network login as always trust
echo host all all 0.0.0.0/0 trust >> /etc/postgresql/9.4/main/pg_hba.conf
#restart server
/etc/init.d/postgresql restart
#change password
psql -U postgres -h localhost -p 5435 postgres -c "ALTER USER postgres WITH PASSWORD 'newpassword'; "
#back to md5
sed -ie 's/host all all 0.0.0.0\/0 trust/host all all 0.0.0.0\/0 md5/g' /etc/postgresql/9.4/main/pg_hba.conf
#restart server
/etc/init.d/postgresql restart
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment