无法连接到服务器:没有这样的文件或目录是服务器在本地运行并接受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)
这个问题/var/run/postgresql/.s.PGSQL.5432
是关于权限的,
你更改数据库目录了吗?如果是,那么你需要给postgres 写和读权限
sudo chown -R postgres:postgres <directory_path>
or
sudo chmod -R 777 <directory_path>
如果不能使用远程访问,请在pg_config
上将此行listen_addresses = 'localhost'
编辑为listen_addresses = '*'
在pg_hba.conf
中插入以下行:
host all all 0.0.0.0/0 md5