Last active
May 9, 2019 17:41
-
-
Save meyt/82adec21fe58eb90ac9209fd75263f3d to your computer and use it in GitHub Desktop.
Quick setup and configure postgres9.x on Ubuntu (development)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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