Skip to content

Instantly share code, notes, and snippets.

@slaveofcode
Created October 18, 2016 16:35
Show Gist options
  • Save slaveofcode/585b2b7d16bac17c6ff1ed98ed34f514 to your computer and use it in GitHub Desktop.
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
# 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