๊ธ€ ์ž‘์„ฑ์ž: ์ด์ง€์›๐ŸŒฉ๏ธ

์šด์˜์ฒด์ œ

Ubuntu 16.04.5 LTS

์„ค์น˜ํ•  ํ”„๋กœ๊ทธ๋žจ

PostgreSQL 11

PostgreSQL ์„ค์น˜

์ด ๋•Œ๋Š” PostgreSQL apt ์ €์žฅ์†Œ๋ฅผ ์ถ”๊ฐ€ํ•˜์—ฌ ์„ค์น˜ํ•  ์ˆ˜ ์žˆ๋‹ค. PostgreSQL apt ์ €์žฅ์†Œ๋Š” ๋‹ค์Œ๊ณผ ๊ฐ™์€ ์šฐ๋ถ„ํˆฌ LTS ๋ฒ„์ „์„ ์ง€์›ํ•œ๋‹ค.

18.04
16.04
14.04

PostgreSQL apt ์ €์žฅ์†Œ๋ฅผ ์ถ”๊ฐ€ํ•˜๋Š” ๋ฒ•์€ ์•„๋ž˜์™€ ๊ฐ™๋‹ค.

  1. /etc/apt/sources.list.d/pgdg.list ํŒŒ์ผ ์ƒ์„ฑ
$ sudo vi /etc/apt/sources.list.d/pgdg.list
  1. pgdg.list์— ๋‚ด์šฉ ์ถ”๊ฐ€ (์šฐ๋ถ„ํˆฌ ๋ฒ„์ „์— ๋”ฐ๋ผ ๋‚ด์šฉ์ด ๋‹ค๋ฆ„)

Bionic (18.04)

deb http://apt.postgresql.org/pub/repos/apt/ bionic-pgdg main

Xenial (16.04)

deb http://apt.postgresql.org/pub/repos/apt/ xenial-pgdg main

Trusty (14.04)

deb http://apt.postgresql.org/pub/repos/apt/ trusty-pgdg main
  1. ํ„ฐ๋ฏธ๋„์— ๋ช…๋ น์–ด ์ž…๋ ฅ
$ wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
sudo apt-get update

PostgreSQL ์„ค์น˜ ๋ช…๋ น์–ด (๋ฒ„์ „ ๋ฒˆํ˜ธ๋ฅผ ๋ณ€๊ฒฝํ•˜์—ฌ ์„ค์น˜ ๊ฐ€๋Šฅ)

$ sudo apt-get install postgresql-11

PostgreSQL ์‚ฌ์šฉ์ž ๊ถŒํ•œ

PostgreSQL์„ ์„ค์น˜ ํ›„, ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค๋ฅผ ์ƒ์„ฑํ•˜๋ ค๊ณ  ํ•˜๋ฉด ๊ถŒํ•œ์ด ์—†๋‹ค๊ณ  ๋œฌ๋‹ค. ์ฐพ์•„๋ณด๋‹ˆ, PostgreSQL์€ ์„ค์น˜ํ•  ๋•Œ ์ž„์˜๋กœ postgres๋ผ๋Š” ๊ณ„์ •์„ ๋งŒ๋“ค๊ณ  ๊ทธ ๊ณ„์ •์—๋งŒ ๊ถŒํ•œ์„ ๋ถ€์—ฌํ•˜๋Š” ๊ฑฐ ๊ฐ™๋‹ค. ๋‚ด ๊ณ„์ •์— ๊ถŒํ•œ์„ ๋ถ€์—ฌํ•˜๋Š” ๋ฐฉ๋ฒ•๋„ ์žˆ์ง€๋งŒ, ๋‚˜๋Š” postgres ๊ณ„์ •์„ ์‚ฌ์šฉํ•˜๊ธฐ๋กœ ํ–ˆ๋‹ค. ๋น„๋ฐ€๋ฒˆํ˜ธ๊ฐ€ ์„ค์ •๋˜์žˆ์ง€ ์•Š์œผ๋‹ˆ, ๋‹ค์Œ ๋ช…๋ น์–ด๋ฅผ ํ†ตํ•ด ๋น„๋ฐ€๋ฒˆํ˜ธ๋ฅผ ์„ค์ •ํ•ด์ค€๋‹ค.

$ sudo passwd postgres

๋‹ค์Œ ๋ช…๋ น์–ด๋ฅผ ํ†ตํ•ด ๊ณ„์ •์„ ๋ณ€๊ฒฝํ•ด์ฃผ์ž.

$ su postgres

PostgreSQL ์ฝ˜์†”๋กœ ์ ‘์†ํ•˜๋Š” ๋ช…๋ น์–ด๋Š” ๋‹ค์Œ๊ณผ ๊ฐ™๋‹ค.

$ psql
postgres@ubuntu:~$ psql
psql (11.1 (Ubuntu 11.1-1.pgdg16.04+1))
Type "help" for help.

postgres=#

๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค ์ƒ์„ฑ, ์‚ฌ์šฉ

createdb ๋ช…๋ น์–ด๋ฅผ ํ†ตํ•ด ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค๋ฅผ ์ƒ์„ฑํ•  ์ˆ˜ ์žˆ๋‹ค. ์ผ๋‹จ ๋‚˜๋Š” android๋ผ๋Š” ์ด๋ฆ„์˜ ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค๋ฅผ ๋งŒ๋“ค๊ธฐ๋กœ ํ–ˆ๋‹ค.

$ createdb android

์•ž์„œ ๋งŒ๋“  android ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค๋ฅผ PostgreSQL ์ฝ˜์†”๋กœ ์ ‘์†ํ•ด๋ณด์ž.

$ psql android
postgres@ubuntu:~$ psql android
psql (11.1 (Ubuntu 11.1-1.pgdg16.04+1))
Type "help" for help.

android=#
๋ฐ˜์‘ํ˜•