【问题标题】:Install and connect to database with psql使用 psql 安装并连接到数据库
【发布时间】:2016-02-28 01:39:49
【问题描述】:

我想在 Centos 6.6 中设置 psql 终端工具

我已获得作为数据库的访问权限,我只想使用终端向数据库写入查询以获取信息。我之前没有使用 psql 的经验,但我想从 pgadmin3 gui 继续前进。

我从安装 psql 开始:

yum install postgresql

但是当我尝试访问它时,即。输入[root@localhost]# psql 我得到以下错误:

psql: FATAL:  database "root" does not exist

我尝试过使用:

psql --host=<DB instance endpoint> --port=<port> --username=<master user name> --password --dbname=<database name>

但这也不起作用,也许这真的很基本,但我完全迷失了这个设置

【问题讨论】:

    标签: database postgresql centos


    【解决方案1】:

    用途:

    psql -U my_pgadmin_username postgres
    

    psql -U my_pgadmin_username -h localhost postgres
    

    另外,更典型的用法:

    sudo -u postgres psql
    

    【讨论】:

    • 所以我可以在输入时访问它:psql -d 'DBNAME' -h 'HOSTNAME' -p PORT -U 'USERNAME',但我根本无法查询它,它只接受我的命令并且什么都不返回
    猜你喜欢
    • 2023-02-12
    • 2021-03-10
    • 1970-01-01
    • 1970-01-01
    • 2016-07-31
    • 2017-08-20
    • 1970-01-01
    • 2014-10-18
    • 1970-01-01
    相关资源
    最近更新 更多