2

我是 postgresql 的新手,我已经在我的计算机上安装了 postgres 并创建了名为的数据库uniprojectv20,还创建了名为的用户uniserved_db并授予了对数据库的所有访问权限uniprojectv20。我正在获取以下问题:

rahul@HP-EliteBook ~ $ psql -V
psql (PostgreSQL) 9.6.3

postgres=# \l
                                     List of databases
     Name      |    Owner     | Encoding | Collate | Ctype |       Access privileges       
---------------+--------------+----------+---------+-------+-------------------------------
 postgres      | postgres     | UTF8     | en_IN   | en_IN | 
 rahul         | postgres     | UTF8     | en_IN   | en_IN | 
 template0     | postgres     | UTF8     | en_IN   | en_IN | =c/postgres                  +
               |              |          |         |       | postgres=CTc/postgres
 template1     | postgres     | UTF8     | en_IN   | en_IN | =c/postgres                  +
               |              |          |         |       | postgres=CTc/postgres
 uniprojectv20 | uniserved_db | UTF8     | en_IN   | en_IN | =Tc/uniserved_db             +
               |              |          |         |       | uniserved_db=CTc/uniserved_db
(5 rows)

postgres=# \q
postgres@HP-EliteBook ~ $ psql -h localhost -p 5432 -U uniserved_db -W uniprojectv20
Password for user uniserved_db: 
**psql: FATAL:  database "uniprojectv20" does not exist**
postgres@HP-EliteBook ~ $ psql uniprojectv20
psql (9.6.3)
Type "help" for help.

uniprojectv20=# 

此外,如果我尝试从另一个用户而不是 postgres 连接,我将面临同样的问题。

rahul@HP-EliteBook ~ $ psql -h localhost -p 5432 -U uniserved_db -W uniprojectv20
Password for user uniserved_db: 
psql: FATAL:  database "uniprojectv20" does not exist
4

1 回答 1

3

您必须在同一台机器上有多个 postgres 集群。所以你有uniprojectv20一个数据库,而不是另一个。

尝试psql -h localhost -p 5433 -U uniserved_db -W uniprojectv20在端口 5433 上进行集群。

要列出所有集群,尝试运行pg_lsclusters它应该会显示数据目录、端口和版本

于 2017-05-25T07:12:31.307 回答