无法启动PostgreSQL

kri*_*a m 7 postgresql

无法连接到服务器:没有这样的文件或目录服务器是否在本地运行并接受Unix域套接字"/var/run/postgresql/.s.PGSQL.5432"上的连接?

我卸载并安装了postgresql,但对我来说没什么用.

$ sudo service postgresql start
 * Starting PostgreSQL 10 database server                                                                                                       
 * Failed to issue method call: Unit postgresql@10-main.service failed to load: No such file or directory. See system logs and 'systemctl status postgresql@10-main.service' for details.

systemctl status postgresql 
Failed to issue method call: No such interface 'org.freedesktop.DBus.Properties' on object at path /org/freedesktop/systemd1/unit/postgresql_2eservice

$ psql -V
psql (PostgreSQL) 10.4 (Ubuntu 10.4-2.pgdg14.04+1)
Run Code Online (Sandbox Code Playgroud)

Hud*_*nPH 2

这个问题/var/run/postgresql/.s.PGSQL.5432是关于权限的,

你改变数据库目录了吗?如果是,那么您需要向 postgres 授予写入和读取权限

sudo chown -R postgres:postgres <directory_path>

or

sudo chmod -R 777 <directory_path>
Run Code Online (Sandbox Code Playgroud)

如果您无法使用远程访问,请pg_config将此行编辑listen_addresses = 'localhost'listen_addresses = '*'

并在pg_hba.conf插入这一行:

host    all  all  0.0.0.0/0  md5
Run Code Online (Sandbox Code Playgroud)