无法在我的系统上运行 postgres。它显示 `postgres 不在 sudoers 文件中。此事件将被报告。

yed*_*ukn 10 postgresql sudo su

我正在尝试在我的 WSL Ubuntu 上安装 postgres。安装完成,但是当我运行时,psql显示以下错误。

psql: error: could not connect to server: 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 find /var/run/postgresql/.s.PGSQL.5432查找该文件时,它显示另一个类似这样的错误。

postgres is not in the sudoers file. This incident will be reported.

从截图中会更清楚。

如何继续?请帮忙...

截屏:

参考

小智 18

此错误似乎是因为您的用户名 iepostgres不在 sudoers 文件中。这就是为什么您无权为postgres用户运行上述命令的原因。

尝试通过以下方式添加用户:

打开文件

sudo nano /etc/sudoers
Run Code Online (Sandbox Code Playgroud)

然后在管理员用户下面添加用户,如下语法所示。

user_name ALL=(ALL)  ALL
Run Code Online (Sandbox Code Playgroud)