업무/sys

Centos 7 Postgresql 10 설치 및 DB 생성

sysops 2018. 7. 8. 00:04
728x90

1.  레포 추가

rpm -Uvh https://yum.postgresql.org/10/redhat/rhel-7-x86_64/pgdg-centos10-10-2.noarch.rpm


2.  설치

yum install -y postgresql10-server postgresql10


3. DB 초기화

/usr/pgsql-10/bin/postgresql-10-setup initdb


Initializing database ... OK


4. systemctl start postgresql-10


5. systemctl enable postgresql-10


6. su - postgres


7. psql


8. DB 생성 및 계정 생성

postgres=# CREATE DATABASE mydb; CREATE DATABASE

postgres=# CREATE USER test WITH PASSWORD 'password1'; CREATE ROLE

postgres=# ALTER ROLE test SET client_encoding TO 'utf8'; ALTER ROLE

postgres=# ALTER ROLE test SET default_transaction_isolation TO 'read committed'; ALTER ROLE

postgres=# ALTER ROLE test SET timezone TO 'UTC-9'; ALTER ROLE


postgres=# GRANT ALL PRIVILEGES ON DATABASE mydb TO test; GRANT


728x90