PostgreSQL managing Role
Checking Role
# accessing with postgres user
sudo -u postgres psql
# check user
\du
Creating Role
# create role in command-line
# answer questions after this command
sudo -u postgres createuser --interactive
# create role in psql prompt
# you can add roles in myrole
sudo -u postgres psql
CREATE ROLE myrole;
Alter Role to user
there’s many role in postgres- LOGIN, CREATEDB, CREATEROLE, etc…
# you can create with some roles to user
CREATE ROLE myrole WITH LOGIN;
# give role after created
ALTER ROLE myrole WTIH CREATEDB;
setting passwords
# setting passwod
\password myrole
setting passwords for user
ALTER USER postgres with password 'password';
give authuization to role
# give all auth of table to role
GRANT ALL ON tablename TO rolename;
# give all privileges to role
GRANT ALL PRIVILEGES ON DATABASE database TO rolename;
'backend > sql (postgres)' 카테고리의 다른 글
Mac (OS X)에 postgres 설치하기 (sierra 10.12.6) (0) | 2017.11.28 |
---|---|
ubuntu postgres systemctl restart 명령어 (0) | 2017.11.22 |
postgres 작동 안될 때 list-dependencies 확인하기 (0) | 2017.11.15 |
다른 서버에서 postgres 접속하기 (5432 포트) (0) | 2017.10.21 |
Postgres restart in ubuntu 16.04 (0) | 2017.10.14 |