我无法连接到 psql

我无法连接到 psql

我输入了psql,但显示这个错误

psql: could not connect to server: No such file or directory
        Is the server running locally and accepting
        connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?

我已经尝试过这些命令:


ahls_cuchi@ubuntu-18-04-template-DND:/var/log/postgresql$ service postgresql status
● postgresql.service - PostgreSQL RDBMS
   Loaded: loaded (/lib/systemd/system/postgresql.service; enabled; vendor preset: enabled)
   Active: active (exited) since Wed 2019-07-10 16:22:34 PDT; 18min ago
  Process: 24295 ExecStart=/bin/true (code=exited, status=0/SUCCESS)
 Main PID: 24295 (code=exited, status=0/SUCCESS)


ahls_cuchi@ubuntu-18-04-template-DND:/var/log/postgresql$ systemctl status [email protected][email protected] - PostgreSQL Cluster 10-main
   Loaded: loaded (/lib/systemd/system/[email protected]; indirect; vendor preset: enabled)
   Active: failed (Result: protocol) since Wed 2019-07-10 16:22:34 PDT; 18min ago
  Process: 24288 ExecStart=/usr/bin/pg_ctlcluster --skip-systemctl-redirect 10-main start (code=exited, status=1/FAILURE)
 Main PID: 4267 (code=exited, status=0/SUCCESS)

ahls_cuchi@ubuntu-18-04-template-DND:/var/log/postgresql$ pg_lsclusters
Ver Cluster Port Status Owner    Data directory              Log file
10  main    5432 down   postgres /var/lib/postgresql/10/main /var/log/postgresql/postgresql-10-main.log


ahls_cuchi@ubuntu-18-04-template-DND:/var/log/postgresql$ sudo pg_ctlcluster 10 main start
Job for [email protected] failed because the service did not take the steps required by its unit configuration.
See "systemctl status [email protected]" and "journalctl -xe" for details.

答案1

遇到了这个问题,奇怪的chown -R postgres/var/,根据这个S/O答案,这是因为权限/var将被更改为非root。

相关内容