1. 사전 작업
$ cat /etc/os-release
$ sudo apt install wget ca-certificates
2. PostgreSQL 저장소 추가
$ sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt/ `lsb_release -cs`-pgdg main" >> /etc/apt/sources.list.d/pgdg.list'
$ sudo apt install wget ca-certificates
$ wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
3. PostgreSQL 설치
$ sudo apt-get update
$ sudo apt show postgresql
4. 설치 확인
$ service postgresql status
● postgresql.service - PostgreSQL RDBMS
Loaded: loaded (/lib/systemd/system/postgresql.service; enabled; vendor preset: enabled)
Active: active (exited) since Wed 2021-09-29 04:12:11 UTC; 1min 1s ago
Main PID: 24254 (code=exited, status=0/SUCCESS)
Tasks: 0 (limit: 4915)
CGroup: /system.slice/postgresql.service
5. 접속 확인
$ sudo su - postgres
$ psql
psql (13.4 (Ubuntu 13.4-1.pgdg18.04+1))
Type "help" for help.
postgres=
You are connected to database "postgres" as user "postgres" via socket in "/var/run/postgresql" at port "5432".
postgres=
6. 사용자 생성
postgres=
postgres=
postgres=
7. Database 생성
postgres=
postgres=