PostgreSQL – Error – “ERROR: permission denied to create database”

Background

If a user tries to create a new database in PostgreSQL, and the user has not been granted the required permission, there is an actionable error that is returned.

Error

Error Image

lacksPermissionToCreateDatabase.20190903.0339PM

Error Text

ERROR: permission denied to create database

Command

So the command issued is :-


>psql.exe -h p2 -U script -d postgres -p 5432 -c "create database bibletoo " 

Remediation

Simply grant “create database” permission.

In PostgreSQL vernacular, the permission is known as CREATEDB.

SQL

SQL – Syntax


ALTER USER {role} with CREATEDB;

SQL – Sample


ALTER USER script with CREATEDB;

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s