我在我的 Ubuntu 16.04 系统上安装了 PostgreSQL 9.6。它似乎已启动并正在运行,但是当我尝试建立连接时它就失败了。当我运行状态命令时,我看到它总是exited
出于某种原因说。我在谷歌搜索中看到了很多东西,但似乎没有任何帮助。
我将 pg_hba.conf 中的第一个条目更改为local all postgres trust
% ps augxw | grep postg
postgres 769 0.0 0.3 303964 24384 ?S 22:13 0:00 /usr/lib/postgresql/9.6/bin/postgres -D /var/lib/postgresql/9.6/main -c config_file=/etc/postgresql/9.6/main/postgresql.conf
postgres 772 0.0 0.0 303964 3956 ? Ss 22:13 0:00 postgres: 9.6/main: checkpointer process
postgres 773 0.0 0.0 303964 3956 ? Ss 22:13 0:00 postgres: 9.6/main: writer process
postgres 774 0.0 0.0 303964 3956?Ss 22:13 0:00 postgres: 9.6/main: wal writer process
postgres 775 0.0 0.0 304408 6572?Ss 22:13 0:00 postgres: 9.6/main: autovacuum 启动器进程
postgres 776 0.0 0.0 158964 3204 ?Ss 22:13 0:00 postgres: 9.6/main: stats collector process
ubuntu 1492 0.0 0.0 12944 936 pts/0 S+ 22:14 0:00 grep postg
%
% sudo su - postgres
$ psql -h localhost
psql:无法连接到服务器:连接
被拒绝服务器是否在主机“localhost”(127.0 .0.1) 并接受
端口 5432 上的 TCP/IP 连接?
$ exit
logout
% systemctl status postgresql
● postgresql.service - PostgreSQL RDBMS
已加载:已加载(/lib/systemd/system/postgresql.service;已启用;供应商预设:已启用)
活动:自 2017 年 3 月 30 日星期四 22 日起活动(已退出) :13:57 PDT;1 分钟 19 秒前
进程:901 ExecStart=/bin/true (code=exited, status=0/SUCCESS)
主 PID: 901 (code=exited, status=0/SUCCESS)
任务: 0
内存: 0B
CPU: 0
CGroup: /system.slice/postgresql.service3 月 30 日 22:13:57 ip-172-31-9-223 systemd[1]:启动 PostgreSQL RDBMS...
3 月 30 日 22:13:57 ip-172-31-9-223 systemd[1]:启动 PostgreSQL关系数据库管理系统。