-
Notifications
You must be signed in to change notification settings - Fork 11
/
postgresql-server.sh
16 lines (13 loc) · 1.03 KB
/
postgresql-server.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#!/bin/bash -eux
# Install postgresql
sudo apt-get install -y postgresql-9.3 postgresql-contrib-9.3 postgresql-client-9.3
# Set password for postgres database user
sudo -u postgres psql postgres postgres -c "ALTER USER postgres WITH ENCRYPTED PASSWORD 'postgres'"
# allow all users to access postgres locally from any user
sudo rm /etc/postgresql/9.3/main/pg_hba.conf
echo "local all all md5"|sudo tee --append /etc/postgresql/9.3/main/pg_hba.conf
echo "local all postgres peer"|sudo tee --append /etc/postgresql/9.3/main/pg_hba.conf
echo "local all all peer"|sudo tee --append /etc/postgresql/9.3/main/pg_hba.conf
echo "host all all 127.0.0.1/32 md5"|sudo tee --append /etc/postgresql/9.3/main/pg_hba.conf
echo "host all all ::1/128 md5"|sudo tee --append /etc/postgresql/9.3/main/pg_hba.conf
sudo service postgresql restart