linux - 无法连接到服务器 : postgresql on ubuntu in windows subsystem for linux

标签 linux windows postgresql ubuntu windows-subsystem-for-linux

我在 ubuntu 18.04 发行版中使用 WSL,在 bash 中我点击了 sudo -u postgres 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.5433"?

然后我尝试了其他 postgres 操作,例如:sudo -u createdb mydb 只会得到同样的错误。

请指教。

最佳答案

当在适用于 Linux 的 Windows 子系统中的 Ubuntu 上运行 PostgreSQL 时,您可能必须在连接之前手动启动数据库服务器。使用下面的命令启动您的数据库服务器,然后尝试连接。

sudo 服务 postgresql 启动

sudo/etc/init.d/postgresql 启动

您还可以检查数据库服务器的状态:

sudo 服务 postgresql 状态

关于linux - 无法连接到服务器 : postgresql on ubuntu in windows subsystem for linux,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51954332/

相关文章:

c - 编写原子函数

c++ - wcscat_s 函数 - 缓冲区错误

c# - Windows 应用程序 - 处理 taskkill

postgresql - postgres 中缓慢的模式/表创建

postgresql - 为什么我的 View 的列可以为空?

PostgreSQL 将 int 值与数字字段连接起来

linux - 如何将数组值添加到文本文件中特定行的开头

Python/Tkinter 应用程序在 Raspberry Pi 启动上运行

python - PyUSB 与 Windows、libusb1 和 libusb-win32 后端不工作

linux - 如何通过 sed 或 awk 递归替换文件中的字符串?