[SOLVED] psql: FATAL database "root" does not exist error

When you were previously using MySQL/MariaDB, you may have encountered this error since you are used to the command mysql-u root -p but PostgreSQL uses a different security model.

C:\Windows\system32>psql -U root
Password for user root:
psql: FATAL:  database "root" does not exist

When you try to acces something in the database using this your terminal will throw this error:

psql: FATAL: database "root" does not exist

Your terminal will throw the following error if you attempt to access the database with this method:

psql: FATAL: database "root" does not exist.

Reason

Logging into Postgresql as someone other than Postgres means you are using the psql command as root and it will attempt to log you into your database. As an example, if you are logged on as Engineer, it will search the database Engineer.

Thus, when it is unable to locate the database root it throws this error

psql: FATAL: database "root" does not exist

In simple terms, if you don't specify the database you want to login to, Psql will use the database with the same name as the database user.

psql -U root -d mydb

If you do not know which database to use or did not create the database before, you can use Postgre's database.


Further Reading

  1. Why map entries are unddressable in Golang?
  2. [SOLVED] ValueError: View function did not return a response
  3. What is Atatus APM and its Benefits?

Monitor your software stack for free with Atatus.

Start your free trial
OR
Request a Demo

Free 14-day trial. No credit card required. Cancel anytime.

Ready to see actionable data?

Avail Atatus features for 14 days free-trial. No credit card required. Instant set-up.