backend/sql (postgres)
postgres basic usage-about Role
seul chan
2017. 10. 22. 09:00
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;