How do I connect to PostgreSQL without specifying a database name?

前端 未结 3 1104
清歌不尽
清歌不尽 2020-12-28 11:49

I need to connect to some PostgreSQL server providing some credentials, and print a list of available databases on that host for a given user.

I am trying:



        
3条回答
  •  旧巷少年郎
    2020-12-28 12:26

    You have to connect to a database. Which database you could use for a "maintenance database" depends on the installation and the subsequent administration. After a default installation there are 2 databases that could be used for the initial connection - "template1" and "postgres". It's wise to create a new user and a database with the same name and use those.

提交回复
热议问题