1

I had a backup of my Mayan-EDMS database which is stored in file.sql. I am trying to restore it. While I am restoring the database using psql -h 127.0.0.1 -U mayan -d mayan -W -f file.sql I got error that saying psql:file.sql:23: ERROR: permission denied to create database. How to remedy this problem?

1 Answers1

2

You have to modify the role mayan:

ALTER ROLE mayan CREATEDB;

Then it can create a database. Perhaps other aspects of restoring the database, like creating an extension, will require still higher privileges.

Laurenz Albe
  • 209,280
  • 17
  • 206
  • 263
  • Thank you very much by the guidence by you alternig the role to superuser now I am able to bypass the error. Now I am getting error saying database "mayan" already exists. Is superuser cant replace database? – Sandaru Akalanka Sep 29 '21 at 12:37
  • Sure, a superuser can do anything. If that is a `pg_dump` you are restoring, create it with `--create --clean`, then it will contain a `DROP DATABASE` statement. Otherwise, add the `DROP DATABASE` to the script manually. – Laurenz Albe Sep 29 '21 at 14:04