Skip to content

Instantly share code, notes, and snippets.

@meyt
Last active May 9, 2019 17:41
Show Gist options
  • Save meyt/82adec21fe58eb90ac9209fd75263f3d to your computer and use it in GitHub Desktop.
Save meyt/82adec21fe58eb90ac9209fd75263f3d to your computer and use it in GitHub Desktop.
Quick setup and configure postgres9.x on Ubuntu (development)
# How to run?
# sudo bash ./setup-postgres.sh
# Install
apt install -y postgresql;
# Set default password "postgres" for postgres user
sudo -u postgres psql -c "ALTER USER postgres WITH PASSWORD 'postgres';";
# Allow all type of connection with md5 authentication
mv -vn /etc/postgresql/10/main/pg_hba.conf /etc/postgresql/10/main/pg_hba.conf.bk
echo "local all postgres md5" > /etc/postgresql/10/main/pg_hba.conf;
echo "host all all 127.0.0.1/32 md5" >> "/etc/postgresql/10/main/pg_hba.conf" ;
systemctl restart postgresql;
# Check connection
PGPASSWORD="postgres" psql -h localhost -U postgres -c 'select 1';
echo "Done!";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment