Install Postgresql 9.6 on Ubuntu via bash script command

PostgreSQL Ubuntu

Download postgresql

add-apt-repository "deb http://apt.postgresql.org/pub/repos/apt/ $(lsb_release -sc)-pgdg main"
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
apt-get update
apt-get install postgresql-9.6 -y

Allow access from outside you need to change “127.0.0.1/23”  to “0.0.0.0/0” and localhost to “* “

sed -i -e 's#127.0.0.1/32#0.0.0.0/0#g' /etc/postgresql/9.6/main/pg_hba.conf
sed -i -e "s/#listen_addresses = 'localhost'/listen_addresses = '*'/g" /etc/postgresql/9.6/main/postgresql.conf

Note : Run this script as administrator.

Leave a Reply

Your email address will not be published. Required fields are marked *