使用 psql 安装并连接到数据库

Install and connect to database with psql

我想在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>

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

使用:

psql -U my_pgadmin_username postgres

psql -U my_pgadmin_username -h localhost postgres

或者,更典型的用法:

sudo -u postgres psql