On Friday 17 February 2017 18:18:20 Michael Tyson wrote:
> postgres=# \q
> pi@raspi ~ $ sudo -u postgres psql testdb
> psql: FATAL: database "testdb" does not exist
> pi@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.