PostgreSQL — Create User, Create Database, Grant privileges/access.

Mohammed Hammoud
1 min readApr 26, 2017

--

Let’s assume that you’ve already have PostgreSQL installed on your Ubuntu machine and that you want to create a user, create a database and grant the user privileges to write/read to/from the database. The following steps should cover that:

1. Switch to postgres user

sudo su postgres

2. Enter the the interactive terminal for working with Postgres

psql

3. Create the database (change database_name)

CREATE DATABASE database_name;

4. Create user (change my_username and my_password)

CREATE USER my_username WITH PASSWORD 'my_password';

5. Grant privileges on database to user

GRANT ALL PRIVILEGES ON DATABASE "database_name" to my_username;

Happy hacking…

--

--

Mohammed Hammoud

Digital Designer, Backend and Frontend developer from Sweden with experience in usability.