๐Ÿฅ Web/โ” Back-end | etc.

[PostgreSQL] Windows ์™ธ๋ถ€ ์ ‘์† ํ—ˆ์šฉ ์„ค์ • ๋ฐ ์™ธ๋ถ€ ์ ‘์† ๋ฐฉ๋ฒ•

darly213 2023. 11. 3. 11:08
728x90

postgresql.conf ์ˆ˜์ •

C:\Program Files\PostgreSQL\15\data_ ๊ฒฝ๋กœ์— postgresql.conf

listen_addresses = '*'

๋กœ ์„ค์ • - ๋ชจ๋“  ip ์ฃผ์†Œ์—์„œ ์ ‘์† ํ—ˆ์šฉ
white list ip ์„ค์ •ํ•˜๊ณ  ์‹ถ์œผ๋ฉด ip ์ฃผ์†Œ ์“ฐ๊ธฐ

ps_hba.conf ์ˆ˜์ •

C:\Program Files\PostgreSQL\15\data ๊ฒฝ๋กœ์— pg_hba.conf

# IPv4 local connections:

host    all             all             0.0.0.0/0            scram-sha-256

IPv4 local connection address 0.0.0.0/0 ์œผ๋กœ ์ˆ˜์ •(์›๋ž˜๋Š” 127.0.0.1)

๋ฐฉํ™”๋ฒฝ ์„ค์ •

๊ณ ๊ธ‰ ๋ณด์•ˆ์ด ํฌํ•จ๋œ windows defender ๋ฐฉํ™”๋ฒฝ

  • ์ธ๋ฐ”์šด๋“œ ๊ทœ์น™ - ์ƒˆ ๊ทœ์น™
  • ํฌํŠธ
  • tcp
  • ํŠน์ • ๋กœ์ปฌ ํฌํŠธ - 5432
  • ์—ฐ๊ฒฐ ํ—ˆ์šฉ
  • ๋„๋ฉ”์ธ/๊ฐœ์ธ/๊ณต์šฉ ๋ชจ๋‘ ์ ์šฉ
  • ์ด๋ฆ„ - PostgreSQL

์ด๋ ‡๊ฒŒ ํ•˜๋ฉด ์™ธ๋ถ€ ์ ‘์† ์„ค์ •์€ ๋๋‚ฌ๋‹ค. ์ด์ œ ๋ฆฌ๋ˆ…์Šค ์ชฝ์—์„œ ์ ‘์†ํ•ด๋ณด์ž.

linux ํ™˜๊ฒฝ์—์„œ ์ ‘์†ํ•˜๊ธฐ(raspberry pi 4, ubuntu 22.04 jammy)

linux(postgreSQL ์„ค์น˜ ํ•„์š”)

$ sudo apt update && sudo apt upgrade -y 
$ sudo apt install curl ca-certificates gnupg -y 
$ curl https://www.postgresql.org/media/keys/ACCC4CF8.asc | gpg --dearmor | sudo tee /etc/apt/trusted.gpg.d/apt.postgresql.org.gpg >/dev/null 
$ 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 -y install postgresql-15 
$ sudo apt install postgresql-common 
$ sudo sh /usr/share/postgresql-common/pgdg/apt.postgresql.org.sh

์„ค์น˜ ํ™•์ธ - ํ™œ์„ฑํ™”

$ psql --version
$ sudo systemctl status postgresql

active๋ผ๊ณ  ๋‚˜์˜ค๋ฉด ์‹คํ–‰ ์ค‘, ์•„๋‹Œ ๊ฒฝ์šฐ์—๋Š”

$ sudo systemctl start postgresql

windows ์„œ๋ฒ„๋กœ ์ ‘์†ํ•ด๋ณด๊ธฐ

psql -h {server_ip} -U {username} -d {database_name}

password๋Š” username password๋กœ ์„ค์ •ํ•œ๋Œ€๋กœ ์น˜๊ณ  ๋“ค์–ด๊ฐ€์ฃผ๋ฉด ๋จ

๊ตฟ ๋๋‹ค.

728x90