Wednesday 25 November 2020

Create PostgreSQL Database and User in Ubuntu

 Enter the psql command line by hitting

sudo -u postgres psql

 

Create the database by using the command. (don't forget to put your database name in place of: yourdbname )

CREATE DATABASE yourdbname;


Create a user with an encrypted password by using the command: (change youruser to your username and yourpass to your password. Password comes in the single comas)

CREATE USER youruser WITH ENCRYPTED PASSWORD 'yourpass';


 Grant all privileges to your new user on your new database. (again provide your username and database name)

GRANT ALL PRIVILEGES ON DATABASE yourdbname TO youruser;