Will & Skill Developers

Will & Skill Developers


Thoughts, snippets and ideas from the team at Will & Skill AB, Stockholm.

Faisal Mahmud
Author

“The mind is not a vessel to be filled, but a fire to be kindled.” ― Plutarch

Share


Create a PostgreSQL user and grant access to database

Faisal MahmudFaisal Mahmud

PostgreSQL is a great database engine, especially when used with Django.

In this simple tutorial we will

  1. Create a USER

    CREATE USER johnnybravo WITH PASSWORD 'bulletproof';
    
  2. Create a DATABASE

    CREATE DATABASE johnnybase;
    
  3. Give the USER full access to the DATABASE

    GRANT ALL PRIVILEGES ON DATABASE johnnybase to johnnybravo;
    

That's it! Your terminal should look like

faisal@vps:~$ sudo su postgres
postgres@vps:~$ psql
psql (9.4.1)
Type "help" for help.

postgres=# CREATE USER johnnybravo WITH PASSWORD 'bulletproof';
CREATE ROLE
postgres=# CREATE DATABASE johnnybase;
CREATE DATABASE
postgres=# GRANT ALL PRIVILEGES ON DATABASE johnnybase to johnnybravo;
GRANT
postgres=# \q
Faisal Mahmud
Author

Faisal Mahmud

“The mind is not a vessel to be filled, but a fire to be kindled.” ― Plutarch

Comments