๐๐ป Xubuntu๋ Ubuntu ๊ธฐ๋ฐ์ด๋ฏ๋ก PostgreSQL ์ค์น ๋ฐฉ๋ฒ์ด Ubuntu์ ์์ ํ ๋์ผํฉ๋๋ค. ์๋์ ๋จ๊ณ๋ณ๋ก ์๋ด๋๋ฆฌ๊ฒ ์ต๋๋ค.
Since Xubuntu is based on Ubuntu, the PostgreSQL installation process is exactly the same as Ubuntu. We’ll walk you through the steps below.
1. ๊ธฐ๋ณธ Ubuntu ์ ์ฅ์์์ ์ค์น (๊ฐ์ฅ ๊ฐ๋จํ ๋ฐฉ๋ฒ, ์ถ์ฒ ์ด๋ณด์)
Install from the default Ubuntu repositories (simplest method, recommended for beginners)
์ด ๋ฐฉ๋ฒ์ผ๋ก ์ค์นํ๋ฉด Xubuntu์ ํ์ฌ ๋ฒ์ (2025๋
12์ ๊ธฐ์ค ์ต์ ๋ฆด๋ฆฌ์ค)์ ๋ง๋ ์์ ์ ์ธ PostgreSQL ๋ฒ์ ์ ์ป์ ์ ์์ต๋๋ค.
Installing this way will give you a stable PostgreSQL version that matches the current version of Xubuntu (latest release as of December 2025).
ํฐ๋ฏธ๋์ ์ด๊ณ ๋ค์ ๋ช
๋ น์ด๋ฅผ ์์๋๋ก ์คํํ์ธ์:
Open a terminal and run the following commands in order:
sudo apt update
sudo apt install postgresql postgresql-contrib
postgresql: ์๋ฒ ๋ณธ์ฒด / server body
postgresql-contrib: ์ถ๊ฐ ํ์ฅ ๊ธฐ๋ฅ / Additional extensions
์ค์น ํ PostgreSQL ์๋น์ค๊ฐ ์๋์ผ๋ก ์์๋ฉ๋๋ค. ์ํ ํ์ธ:
After installation, the PostgreSQL service will start automatically. Check its status:
sudo systemctl status postgresql
๋๋ / or
service postgresql status
2. ์ต์ ๋ฒ์ ์ค์น (๊ณต์ PostgreSQL ์ ์ฅ์ ์ฌ์ฉ)
Install the latest version (using the official PostgreSQL repository)
Ubuntu ๊ธฐ๋ณธ ์ ์ฅ์ ๋ฒ์ ์ด ์๋ ์ต์ PostgreSQL (์: 17 ๋๋ 18)์ ์ํ ๊ฒฝ์ฐ ๊ณต์ ์ ์ฅ์๋ฅผ ์ถ๊ฐํ์ธ์.
If you want a newer PostgreSQL version (e.g. 17 or 18) than the Ubuntu default repository version, add the official repository.
sudo apt install -y postgresql-common
sudo /usr/share/postgresql-common/pgdg/apt.postgresql.org.sh
์คํฌ๋ฆฝํธ๊ฐ ์คํ๋๋ฉฐ ์ ์ฅ์๋ฅผ ์๋ ์ถ๊ฐํฉ๋๋ค. ๊ทธ๋ฆฌ๊ณ ์๋ ๋ช
๋ น์ด๋ฅผ ์คํํฉ๋๋ค.
The script will run and automatically add the repository. Then, run the command below.
sudo apt update
# ์ต์ ๋ฒ์ ์๋ ์ค์น / Install latest version automatically
sudo apt install postgresql
# ๋๋ ํน์ ๋ฒ์ ์ง์ (์: 17) / or specify a specific version (e.g. 17)
sudo apt install postgresql-17
3.ํค๋ณด๋ ์
๋ ฅ์ด ์๋จนํ๊ณ ๋ชป ๋น ์ ธ๋๊ฐ๋
When keyboard input doesn’t work and you can’t exit
psql์์ ๊ฐ๋ ์
๋ ฅ ๋ชจ๋๊ฐ ์ด์ํด์ ธ์ ํค ์
๋ ฅ์ด ์ ๋จนํ๋ ๊ฒ์ฒ๋ผ ๋ณด์ผ ์ ์์ต๋๋ค.
Ctrl + C ๋ฅผ ํ ๋ฒ ๋๋ฌ๋ณด์ธ์.
โ ํ์ฌ ์
๋ ฅ ์ค์ด ์ทจ์๋๊ณ ์ ํ๋กฌํํธ(postgres=#)๊ฐ ๋ํ๋ฉ๋๋ค.
์ด๊ฒ ์ ์ผ ํจ๊ณผ์ ์ธ ๊ฒฝ์ฐ๊ฐ ๋ง์์!
์ ๋๋ฉด Ctrl + Z ๋๋ฌ์ psql์ ์ผ์ ์ ์งํ ํ, ํฐ๋ฏธ๋์์ fg ์
๋ ฅํด์ ๋ค์ ๋ถ๋ฌ์ค์ธ์.
: ์ด๋ฐ ํ๋กฌํํธ ์ํ์ผ๊ฒฝ์ฐ q์ ์
๋ ฅํ๋ฉด ๋น ์ ธ๋๊ฐ๋๋ค.
\q ๋ ctrl + c ํ๋ฉด ์ข
๋ฃ๋ฉ๋๋ค.
Sometimes psql's input mode can get weird, making it seem like your keystrokes aren't working.
Try pressing Ctrl + C.
โ This will cancel the current input line and bring up a new prompt (postgres=#).
This often works best!
If that doesn't work, press Ctrl + Z to pause psql, then type fg in the terminal to reload it.
: If you see this prompt, type q to exit.
\q or Ctrl + C will exit.
4. PostgreSQL ์๋ฒ์ ํด๋ผ์ด์ธํธ๋ง ์ญ์ (๋ฐ์ดํฐ๋ ๋จ๊น, ๋์ค์ ์ฌ์ค์น ๊ฐ๋ฅ)
Delete only the PostgreSQL server and client (leaving data behind, so you can reinstall later)
๋ฐ์ดํฐ๋ฒ ์ด์ค ํ์ผ์ ๊ทธ๋๋ก ๋จ์์ ๋์ค์ ์ฌ์ค์นํ๋ฉด ๊ธฐ์กด ๋ฐ์ดํฐ ๋ณต๊ตฌ ๊ฐ๋ฅ.
The database files remain intact, allowing you to recover existing data later when reinstalling.
sudo apt remove postgresql postgresql-contrib
# ๋ถํ์ํ ์ข
์ ํจํค์ง๊น์ง ์ ๊ฑฐ
# Remove unnecessary dependent packages
sudo apt autoremove
5.PostgreSQL ์์ ์ญ์ (์ค์ ํ์ผ + ๋ฐ์ดํฐ๊น์ง ๋ชจ๋ ์ ๊ฑฐ, ์ถ์ฒ ๋๋ถ๋ถ ๊ฒฝ์ฐ)
Completely uninstall PostgreSQL (removes all configuration files and data, recommended in most cases)
๋ฐ์ดํฐ๋ฒ ์ด์ค ํ์ผ๊น์ง ์์ ํ ์ญ์ ๋ฉ๋๋ค. ๊ธฐ์กด ๋ฐ์ดํฐ๊ฐ ํ์ ์์ผ๋ฉด ์ด ๋ฐฉ๋ฒ ์ฌ์ฉํ์ธ์.
This will completely delete all of your database files. Use this method if you no longer need your existing data.
๐๐ป #๋ฒํธ ๋ธ๋ญ ๋จ์๋ก ๋ช ๋ น์ด ์คํํ ๊ฒ / Execute commands in number block units
# 1. ํจํค์ง ์์ ์ ๊ฑฐ (์ค์ ํ์ผ๊น์ง ์ญ์ )
# Completely remove the package (including the configuration file)
sudo apt purge postgresql postgresql-contrib postgresql-* pgadmin* -y
# ๋จ์ ์ข
์ ํจํค์ง๊น์ง ์ ๊ฑฐ / Remove remaining dependent packages
sudo apt autoremove -y
# 2. ๋จ์ ์ค์ ํ์ผ๊ณผ ๋ฐ์ดํฐ ๋๋ ํฐ๋ฆฌ ์๋ ์ญ์
# Manually delete remaining configuration files and data directories.
sudo rm -rf /etc/postgresql/
sudo rm -rf /var/lib/postgresql/
# 3. PostgreSQL ์๋น์ค ์ ์ง ๋ฐ ์๋ ์์ ๋นํ์ฑํ
# Stop the PostgreSQL service and disable autostart.
sudo systemctl stop postgresql 2>/dev/null
sudo systemctl disable postgresql 2>/dev/null
sudo systemctl stop postgresql@*-main 2>/dev/null
# 4. ๋จ์ ์๋ ๋ชจ๋ postgres ํ๋ก์ธ์ค ๊ฐ์ ์ข
๋ฃ (ํต์ฌ!)
# Force kill all remaining postgres processes (critical!)
sudo pkill -9 -u postgres 2>/dev/null
sudo killall -9 -u postgres 2>/dev/null
# 5. postgres ๋ฆฌ๋
์ค ์ฌ์ฉ์ ์ญ์
# Delete the postgres Linux user
# -- 2>/dev/null :์๋ฌ ๋ฉ์ธ์ง๊ฐ ๋ฐ์ํ๋ฉด ์ถ๋ ฅํ์ง ์๊ณ ๋ฒ๋ฆผ
# -- 2>/dev/null: If an error message occurs, it is discarded without being printed.
sudo userdel -r postgres 2>/dev/null || sudo deluser --remove-home postgres 2>/dev/null
# 6. postgres ๊ทธ๋ฃน ์ญ์
# Delete the postgres group
sudo groupdel postgres 2>/dev/null || sudo delgroup postgres 2>/dev/null
# 7. (์ ํ) ๋จ์ ํ์ผ ์ต์ข
ํ์ธ ๋ฐ ์ญ์
# (Optional) Final check and deletion of remaining files
sudo find / -name "*postgres*" -exec rm -rf {} + 2>/dev/null
์ญ์ ํ ํ์ธ ๋ฐฉ๋ฒ / How to check after deletion
# ์ค์น ์ฌ๋ถ ํ์ธ
# Check if installed
dpkg -l | grep postgres
# ์๋น์ค ์คํ ์ฌ๋ถ ํ์ธ
# Check if the service is running
sudo systemctl status postgresql
# "Unit postgresql.service could not be found." ๋ฉ์ธ์ง ๋์ค๋ฉด ์์ ์ญ์ ์ฑ๊ณต
# If the message "Unit postgresql.service could not be found." appears, complete deletion was successful.