psql: error: FATAL: database “XXX” does not exist

Wajeeh Ahsan
Jan 7, 2021

--

This is because, postgres isn’t having a role with this name. To get rid of this error, you need to create this role. Make sure the name of the new role is same as showing in the error message. I suppose its XXX . Lets do this.

Run the following comand:

sudo -i -u postgres

Then login to psql with the default and superuser provided by default i.e postgres . Run this command now.

psql -U postgres

It will take you to the psql shell. Here you can create your role. Run the following command to create a simple role.

CREATE ROLE XXX WITH LOGIN ENCRYPTED PASSWORD 'YYYYY';

This will create a role names XXX with password YYYY .

To see all roles and their privileges, run the following command.

\du

Type \q to exit. We’re done.

--

--

Wajeeh Ahsan
Wajeeh Ahsan

No responses yet