PostgreSQL 사용자 권한 생성 및 사용자 생성

DB/Postgresql|2021. 8. 4. 23:31

PostgreSQL 사용자 권한 생성 및 사용자 생성

postgreSQL 접속

psql postgres

\du 명령어를 입력합니다.

postgres=# \du

실행결과

                                   List of roles
 Role name |                         Attributes                         | Member of 
-----------+------------------------------------------------------------+-----------
 goodsaem  | Superuser, Create role, Create DB, Replication, Bypass RLS | {}

goodsaem 유저의 패스워드를 변경합니다.

postgres=# \password goodsaem
Enter new password: 
Enter it again:

 

신규 유저 생성

CREATE USER aptdb PASSWORD 'aptdb' SUPERUSER;

신규 유저로 로그인

psql postgres -U aptdb

데이터베이스 생성

CREATE DATABASE aptdb;

생성된 DB 확인

postgres=# \l

실행결과

postgres=# \l
                             List of databases
   Name    |  Owner   | Encoding | Collate | Ctype |   Access privileges   
-----------+----------+----------+---------+-------+-----------------------
 aptdb     | aptdb    | UTF8     | C       | C     | 
 postgres  | goodsaem | UTF8     | C       | C     | 
 template0 | goodsaem | UTF8     | C       | C     | =c/goodsaem          +
           |          |          |         |       | goodsaem=CTc/goodsaem
 template1 | goodsaem | UTF8     | C       | C     | =c/goodsaem          +
           |          |          |         |       | goodsaem=CTc/goodsaem
(4 rows)

'DB > Postgresql' 카테고리의 다른 글

[mac] postgresql 외부접속 가능하게 변경  (0) 2021.08.15
[mac] postgresql 서비스 시작/종료  (0) 2021.08.15
windows 에 PostgreSQL 설치  (0) 2021.08.05
PostgreSQL 테이블 생성  (0) 2021.08.04
Mac 맥에 PostgresSQL 설치하기  (0) 2021.08.04

댓글()