postgresql – psql: FATAL: database does not exist

postgresql – psql: FATAL: database does not exist

It appears that your package manager failed to create the database named $user for you. The reason that

psql -d template1

works for you is that template1 is a database created by postgres itself, and is present on all installations.
You are apparently able to log in to template1, so you must have some rights assigned to you by the database. Try this at a shell prompt:

createdb

and then see if you can log in again with

psql -h localhost

This will simply create a database for your login user, which I think is what you are looking for. If createdb fails, then you dont have enough rights to make your own database, and you will have to figure out how to fix the homebrew package.

From the terminal, just Run the command on your command prompt window. (Not inside psql).

createdb <user>

And then try to run postgres again.

postgresql – psql: FATAL: database does not exist

By default, postgres tries to connect to a database with the same name as your user. To prevent this default behaviour, just specify user and database:

psql -U Username DatabaseName 

Leave a Reply

Your email address will not be published.