Created
October 18, 2016 16:35
-
-
Save slaveofcode/585b2b7d16bac17c6ff1ed98ed34f514 to your computer and use it in GitHub Desktop.
Create a new role/user and database, then assign the user into the database in postgres
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Create a new user on linux first | |
>> adduser aditya | |
# Change the password | |
>> passwd aditya | |
# Login as root and go into psql | |
>> su - root | |
# Login as postgres user | |
>> su - postgres | |
# Try psql, we will go into postgres sql console | |
>> psql | |
# Create a new user in postgres | |
>> CREATE USER codeslave WITH PASSWORD 'aditya'; | |
CREATE ROLE | |
# Create a new database | |
>> CREATE DATABASE buntutkacang; | |
CREATE DATABASE | |
# Make grant all access for user 'aditya' | |
>> GRANT ALL PRIVILEGES ON DATABASE buntutkacang TO aditya; | |
GRANT | |
# See the result | |
>> \l | |
# Quit | |
>> \q |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment