by

Postgresql – create a database

Log in to the database:

psql -U postgres

Execute the following commands:

CREATE DATABASE yourdbname;
CREATE USER youruser WITH ENCRYPTED PASSWORD 'yourpass';
GRANT ALL PRIVILEGES ON DATABASE yourdbname TO youruser;

For PostgreSQL servers with versions greater than 15, we have to run the following:

\c yourdbname
GRANT USAGE, CREATE ON SCHEMA public TO youruser;

Write a Comment

Comment