DB/Postgres
[Postgres] ubuntu에 postgres 설치
안젤라님
2022. 5. 11. 16:33
1. 설치
apt-get update
apt-get install postgresql postgresql-contrib
2. 접속
sudo -i -u postgres
psql
3. 설정
1. postgresql.conf 설정
- 서버를 처음깔면 localhost로 설정되어있음. 따라서 local PC에서만 접근이 가능. '*' 로 바꾸어야 외부 접근이 가능.
(특정 IP 접근만 허용하고자 한다면 해당 IP 기재)
vi /etc/postgresql/12/main/postgresql.conf
listen_addresses = '*'
2. pg_hba.conf 설정
vi /etc/postgresql/12/main/pg_hba.conf
# Database administrative login by Unix domain socket
local all postgres peer
# TYPE DATABASE USER ADDRESS METHOD
# "local" is for Unix domain socket connections only
local all all peer
# IPv4 local connections:
host all all 0.0.0.0/0 md5
#host all all 127.0.0.1/32 md5
# IPv6 local connections:
host all all ::1/128 md5
# Allow replication connections from localhost, by a user with the
# replication privilege.
local replication all peer
host replication all 127.0.0.1/32 md5
host replication all ::1/128 md5