我遇到了postgresql的问题,当我尝试用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"?
我在网上找到的解决方案是更改此文件的访问权限:
sudo chmod 777 /var/run/postgresql 并通过此命令行重启postgresql pg_ctl -D /home/mycomputer/var/postgres/ -l logfile restart
我作为postgres用户登录 sudo su postgres 但是现在我收到此错误消息: psql: FATAL: role "postgres" does not exist
我在网上搜索过,但没有找到解决这个问题的好方法 .
请有人帮我这个 . 先感谢您
1 回答
停止数据库服务器并以单用户模式启动它 .
然后,您可以查询有哪些用户 .
您必须弄清楚系统上安装
postgres
可执行文件的位置,例如:与pg_config --bindir
. 我将在下面假设/path/to/postgres/bin
.成为PostgreSQL操作系统用户(通常为
postgres
) .使用停止PostgreSQL服务器
Ctrl+D
关闭数据库 .现在您了解该PostgreSQL集群中的所有用户 .
您可以启动数据库服务器并使用其中一个连接到数据库 .