👉🏻 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.