dnf install postgresql-server -ypostgresql-setup initdbsystemctl enable postgresql; systemctl start postgresqlsystemctl status postgresqlss -pltnsu - postgres
su: switch userpsql
- postgreSQL 접속
- [postgres=#]
CREATE ROLE dba;
CREATE DATABASE comento;
GRANT ALL PRIVILEGES ON DATABASE comento TO dba;
ALTER USER dba PASSWORD 'dba';
ALTER DATABASE comento OWNER TO dba;
- 해당 계정에서 사용할 데이터베이스 연결
\l: db 목록 조회(list)
\q: psql 종료
위의 상태에서는 외부에서 DB에 접속할 수가 없다. 따라서 다음 사항을 진행.
vim /var/lib/pgsql/data/postgresql.conf
listen_addresses = '*' # what IP address(es) to listen on;vim /var/lib/pgsql/data/pg_hba.conf
host all all 0.0.0.0/0 trust 입력su -: root 계정으로 돌아옴
systemctl restart postgresql
ss -pltn | grep post
grep: post에서 실행중인 프로세스를 찾는 것su - postgres
psql -h [dbmIP] -d comento -U dba -W
psql -U 유저명 -d DB명-h host명: 서버가 돌아가는 호스트명 -W: 비밀번호를 입력하겠다comento=>pg_restore -U postgres -d comento dvdrental.tarpg_restore [옵션] [파일명]-d: DB명-U: 백업 시 접속할 사용자명psql 접속 후,
\c comento
\c [DB name] [Connection User]\dt
ALTER TABLE actor OWNER TO dba;
dnf install postgresql -ypsql -h [db ip] -d comento -U dba -W