반응형
오늘은 Postgresql을 Rocky list 9.5에 설치하는 법에 대해 알아보자.
다행 스럽게도 가이드가 잘 되어있다.
설치
https://www.postgresql.org/download/linux/redhat/
PostgreSQL: Linux downloads (Red Hat family)
Linux downloads (Red Hat family) The Red Hat family of distributions includes: Red Hat Enterprise Linux Rocky Linux AlmaLinux CentOS (7 only) Fedora Oracle Linux and others. PostgreSQL is available on these platforms by default. However, each version of th
www.postgresql.org
Rocky linux에서는 PostgreSQL Yum Repository 항목을 참고한다.
원하는 버전, OS, 아키텍처를 선택하면 스크립트가 생성된다.
나는 macOS의 vmware fusion에 arm64용으로 설치하였으므로 위와 같이 선택하였다.
sudo dnf install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-9-aarch64/pgdg-redhat-repo-latest.noarch.rpm
sudo dnf -qy module disable postgresql
sudo dnf install -y postgresql15-server
sudo /usr/pgsql-15/bin/postgresql-15-setup initdb
sudo systemctl enable postgresql-15
sudo systemctl start postgresql-15
설치 확인
설치가 다되었으면 다음과 같이 확인 해볼 수 있다.
sudo -i -u postgres
psql -c "SELECT version();"
postgres 계정으로 로그온하여 psql 커멘드를 날려본다.
db에 접속하는 방법은 다음과 같다.
sudo -i -u postgres
psql
간단한 명령어
데이터베이스 보기
\l
접속중인 사용자
\conninfo
종료하기
\q
나는 mysql정도가 익숙한데 너무 생소해서 좀 비교를 해보았다.
항목 | MySQL | PostgreSQL |
---|---|---|
접속 | mysql -u root -p |
sudo -i -u postgres → psql |
데이터베이스 목록 보기 | SHOW DATABASES; |
\l |
데이터베이스 선택 | USE 데이터베이스명; |
\c 데이터베이스명 |
테이블 목록 보기 | SHOW TABLES; |
\dt |
현재 접속 정보 보기 | SELECT database(); |
\conninfo |
사용자 목록 보기 | SELECT user FROM mysql.user; |
\du |
새 데이터베이스 생성 | CREATE DATABASE db명; |
CREATE DATABASE db명; |
새 사용자 생성 | CREATE USER 'user'@'host' IDENTIFIED BY 'pw'; |
CREATE USER user WITH PASSWORD 'pw'; |
권한 부여 | GRANT ALL ON db.* TO 'user'@'host'; |
GRANT ALL PRIVILEGES ON DATABASE db TO user; |
포트 번호 | 3306 | 5432 |
종료 | exit |
\q |
버전 확인 | SELECT VERSION(); |
SELECT version(); |
반응형
'개발 > Linux' 카테고리의 다른 글
PM2를 이용한 Node.js(Next.js) 서버 백그라운드 실행하기(+ selinux) (0) | 2025.06.03 |
---|---|
Postgresql 15 외부접속 허용하기 (rocky linux 9.5) (0) | 2025.05.01 |
Rocky linux 9.5 - nginx, php 설치 (1) | 2025.04.28 |
[shell script] if 파일 존재 여부 체크하기 (0) | 2024.03.13 |
우분투 윈도우 듀얼부팅 시간 차이 문제 해결 (0) | 2022.04.02 |
댓글