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]
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
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).
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)
also happened to me on a virgin Mavericks install. Had to createdb USERNAME myself.
PS. thanks for maintaining Postgres.app, I love it.
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)
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!
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
is there a solution to this yet ? I am getting the same error
just do like this:
step 1: createdb
step 2: psql -h localhost or psql
hope useful to you.
When I type createdb USERNAME i get the response command not found, could you assist me?
createdb USERNAME command in Terminal.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.
createdb -h localhost -p 5432 -U <USERNAME> testDB
psql testDB
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.
thank you so mucccch
Most helpful comment
Could you try connecting to the "postgres" database:
psql -d postgresand then execute the following command:
show data_directory;On 9.3.1.0-alpha1 that should return
/Users/USERNAME/Library/Application Support/Postgres93/varThen check which databases exist on the server using the shorthand
\lIf all that works, it seems that Postgresapp called initdb successfully, but createdb failed. You can do that manually, just execute
createdb USERNAMEfrom the terminal (not inside psql)