[Solved] psql: FATAL: database “” does not exist

Login using default template1 database:

#psql -d template1
#template1=# \l

  List of databases
   Name    |  Owner  | Encoding |   Collate   |    Ctype    |  Access privileges  
-----------+---------+----------+-------------+-------------+---------------------
 postgres  | gogasca | UTF8     | en_US.UTF-8 | en_US.UTF-8 | 
 template0 | gogasca | UTF8     | en_US.UTF-8 | en_US.UTF-8 | =c/gogasca         +
           |         |          |             |             | gogasca=CTc/gogasca
 template1 | gogasca | UTF8     | en_US.UTF-8 | en_US.UTF-8 | =c/gogasca         +
           |         |          |             |             | gogasca=CTc/gogasca
(3 rows)

Create a database with your userId:

template1=# CREATE DATABASE gogasca WITH OWNER gogasca ENCODING 'UTF8';
CREATE DATABASE

Quit and then login again

template1=# \q
gonzo:~ gogasca$ psql -h localhost
psql (9.4.0)
Type "help" for help.

gogasca=# \l
                                List of databases
   Name    |  Owner  | Encoding |   Collate   |    Ctype    |  Access privileges  
-----------+---------+----------+-------------+-------------+---------------------
 gogasca   | gogasca | UTF8     | en_US.UTF-8 | en_US.UTF-8 | 
 postgres  | gogasca | UTF8     | en_US.UTF-8 | en_US.UTF-8 | 
 template0 | gogasca | UTF8     | en_US.UTF-8 | en_US.UTF-8 | =c/gogasca         +
           |         |          |             |             | gogasca=CTc/gogasca
 template1 | gogasca | UTF8     | en_US.UTF-8 | en_US.UTF-8 | =c/gogasca         +
           |         |          |             |             | gogasca=CTc/gogasca
(4 rows)

Similar Posts: