Re: "Database does not exist" weirdness

From: Alan Hodgson <ahodgson(at)lists(dot)simkin(dot)ca>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: "Database does not exist" weirdness
Date: 2017-02-17 18:29:03
Message-ID: 6421366.bTpXBSyCdR@skynet.simkin.ca
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Friday 17 February 2017 18:18:20 Michael Tyson wrote:
> postgres=# \q
> pi(at)raspi ~ $ sudo -u postgres psql testdb
> psql: FATAL: database "testdb" does not exist
> pi(at)raspi ~ $ sudo -u postgres createdb testdb
> createdb: database creation failed: ERROR: duplicate key value violates
> unique constraint "pg_database_datname_index" DETAIL: Key
> (datname)=(testdb) already exists.
>

Something's seriously borked in your PostgreSQL data files. The message it
should give you if the database exists is:

createdb: database creation failed: ERROR: database "testdb" already exists

It looks like it partially exists in the catalog but not really. I can't guess
how you got to such a state, but you should probably nuke your data directory
and start over with a fresh initdb.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2017-02-17 18:29:30 Re: "Database does not exist" weirdness
Previous Message Tim Bellis 2017-02-17 16:02:09 Re: Autovacuum stuck for hours, blocking queries