postgresql 12 install on ubuntu 18.04

2020. 3. 16. 20:07SQL

Step1 : Update System

sudo apt update
sudo apt -y install bash-completion wget
sudo apt -y upgrade

sudo reboot

Step2 : Add repository

wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -

echo "deb http://apt.postgresql.org/pub/repos/apt/ `lsb_release -cs`-pgdg main" |sudo tee  /etc/apt/sources.list.d/pgdg.list

Step3 : Install PostgreSQL 12

sudo apt update
sudo apt -y install postgresql-12 postgresql-client-12
systemctl status postgresql.service

systemctl status postgresql@12-main.service

Step4 : Local Connection

sudo su - postgres

psql -c "alter user postgres with password 'password'"

test

root@Deb:/home/dev# su - postgres
postgres@Deb:~$ psql
psql (12.2 (Debian 12.2-2.pgdg90+1))
도움말을 보려면 "help"를 입력하십시오.

postgres=# \conninfo
접속정보: 데이터베이스="postgres", 사용자="postgres", 소켓="/var/run/postgresql", 포트="5432".

postgres=# \l
                                  데이터베이스 목록
   이름    |  소유주  | 인코딩 |   Collate   |    Ctype    |       액세스 권한       
-----------+----------+--------+-------------+-------------+-------------------------
 mytestdb  | postgres | UTF8   | ko_KR.UTF-8 | ko_KR.UTF-8 | =Tc/postgres           +
           |          |        |             |             | postgres=CTc/postgres  +
           |          |        |             |             | mytestuser=CTc/postgres
 postgres  | postgres | UTF8   | ko_KR.UTF-8 | ko_KR.UTF-8 | 
 template0 | postgres | UTF8   | ko_KR.UTF-8 | ko_KR.UTF-8 | =c/postgres            +
           |          |        |             |             | postgres=CTc/postgres
 template1 | postgres | UTF8   | ko_KR.UTF-8 | ko_KR.UTF-8 | =c/postgres            +
           |          |        |             |             | postgres=CTc/postgres
(4개 행)

Step5 : configure remote connection

sudo nano /etc/postgresql/12/main/postgresql.conf 

# Listen on all interfaces
listen_addresses = '*'

OR

# Listen on all interfaces
listen_addresses = 'local-ip'

원격접속지 보안 설정

vi /etc/postgresql/12/main/pg_hba.conf

# TYPE  DATABASE    USER        ADDRESS               METHOD
host    all         all         192.168.0.0/24        md5

 

 

 

 

참조 : https://computingforgeeks.com/install-postgresql-12-on-ubuntu/

'SQL' 카테고리의 다른 글

MySQL 접속 문제 Access denied for user 'root'@'localhost'  (0) 2020.06.10