Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FATAL: database "dave" does not exist #139

Closed
bingomanatee opened this issue Oct 19, 2013 · 15 comments
Closed

FATAL: database "dave" does not exist #139

bingomanatee opened this issue Oct 19, 2013 · 15 comments
Labels

Comments

@bingomanatee
Copy link

using the "psql" menu item (OSX 10.8.4) I get

Last login: Sat Oct 19 07:59:28 on ttys009
/Applications/Postgres.app/Contents/MacOS/bin/psql ; exit;
Daves-MacBook-Pro:~ dave$ /Applications/Postgres.app/Contents/MacOS/bin/psql ; exit;
psql: FATAL: database "dave" does not exist
logout

[Process completed]

@jakob
Copy link
Member

jakob commented Oct 28, 2013

The first time you open Postgres.app, it automatically creates a database named like your username. Apparently this database doesn't exist.

There are a few possible reasons why this database doesn't exist:

  1. You changed your username
  2. psql is not connecting to Postgres.app but to a different server

There are a number of reasons why psql might be connecting to a different server:

  1. Maybe you have a different Postgres installation already running on your Mac
  2. Maybe you already started a copy of Postgres.app as a different user on your machine
  3. Maybe you changed the psql configuration using environment variables PGDATABASE, PGHOST, PGPORT, PGUSER or you changed settings in the file ~/.psqlrc

@Shpigford
Copy link

I'm also getting this error. I'm using the 9.3.1.0-alpha1 pre-release. This is on OS X Mavericks.

$ which psql
/Applications/Postgres93.app/Contents/MacOS/bin/psql

$ psql
psql: FATAL: database "USERNAME" does not exist

I haven't changed my username. My previous Postgres installation isn't running (I force quit all instance of Postgres).

@jakob
Copy link
Member

jakob commented Oct 29, 2013

Could you try connecting to the "postgres" database:
psql -d postgres
and then execute the following command:
show data_directory;
On 9.3.1.0-alpha1 that should return /Users/USERNAME/Library/Application Support/Postgres93/var
Then check which databases exist on the server using the shorthand \l

If all that works, it seems that Postgresapp called initdb successfully, but createdb failed. You can do that manually, just execute createdb USERNAME from the terminal (not inside psql)

@dylanjha
Copy link

also happened to me on a virgin Mavericks install. Had to createdb USERNAME myself.

PS. thanks for maintaining Postgres.app, I love it.

@mcandre
Copy link

mcandre commented May 30, 2014

This bug occurs for me as well using the Homebrew formula for installing PostgreSQL.

Trace:

$ brew install postgresql
...
$ launchctl load ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
$ psql
psql: FATAL:  database "andrew" does not exist

System:

$ specs postgres brew os
Specs:

specs 0.8
https://github.com/mcandre/specs#readme

postgres --version
postgres (PostgreSQL) 9.3.4

brew --version
0.9.5

system_profiler SPSoftwareDataType | grep 'System Version'
      System Version: OS X 10.9.3 (13D65)

@ghost
Copy link

ghost commented Nov 19, 2014

happened to me as well on a Yosemite install while installing a rails app locally.

FATAL: database "USERNAME" does not exist

createdb USERNAME fixed the problem - thanks!

@raychenon
Copy link

I first tried with Homebrew then I ran into this error. Then uninstalled postgres by brew
I installed PostgresApp, this error showed up again.
How can you check if you have previous Postgres installed on the mac ?
I use

which psql
but it will show me /Applications/Postgres.app/Contents/Versions/9.4/bin/psql

@kenju254
Copy link

is there a solution to this yet ? I am getting the same error

@yangman-c
Copy link

just do like this:
step 1: createdb
step 2: psql -h localhost or psql

hope useful to you.

@kultgenj
Copy link

When I type createdb USERNAME i get the response command not found, could you assist me?

@jakob
Copy link
Member

jakob commented Jul 16, 2015

  1. First, make sure you remove older intallations of PostgreSQL before starting Postgres.app. To do so, follow the instructions here: http://postgresapp.com/documentation/remove.html
  2. Restart your Mac after uninstalling other PostgreSQL installations, and open Activity Monitor to make sure there are no processes named "postgres" running.
  3. Now open Postgres.app. If it still doesn't work, try using the createdb USERNAME command in Terminal.
  4. Make sure you set up your $PATH correctly: http://postgresapp.com/documentation/cli-tools.html

@jakob
Copy link
Member

jakob commented Dec 23, 2016

The new version of Postgres.app now checks if the port is in use before attempting to init a server and create a database. This makes it much less likely to fail. Additionally, Postgres.app displays more reasonable error messages when a problem occurs.

And finally, the troubleshooting section in the docs now explains how to fix this problem.

@jakob jakob closed this as completed Dec 23, 2016
@AgoniNemo
Copy link

createdb -h localhost -p 5432 -U <USERNAME> testDB

psql testDB

@sarkarchandan
Copy link

For me as well, "database doesn't exist" error was showing up. While trouble shooting I figured that I accidentally dropped the database with my name that Postgresapp creates while initialising.

I simply created one database with my name and things were fine. Thus, I assume that every time I launch the Postgresapp it checks connection for the database with my name. Please correct me if I am wrong.

Thanks in advance.

@monroe100
Copy link

monroe100 commented Apr 4, 2019

thank you so mucccch

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests