【问题标题】:Unable to connect to server: postgresql on ubuntu in windows subsystem for linux无法连接到服务器:Linux 的 windows 子系统中 ubuntu 上的 postgresql
【发布时间】:2019-01-27 23:25:01
【问题描述】:

我正在使用带有 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 postgresql ubuntu windows-subsystem-for-linux


【解决方案1】:

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

sudo service postgresql start

sudo /etc/init.d/postgresql start

您还可以通过以下方式检查数据库服务器的状态:

sudo service postgresql status

【讨论】:

  • 我遇到了和 OP 一样的问题。该服务正在运行,但即使使用与前一天相同的设置也无法连接到它。我认为 Postgres 只是对 WSL 感到厌烦,或者需要某种 hacky 解决方法。只是去完整的 Linux 人,没有什么比真正的东西...
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2019-08-26
  • 2018-02-28
  • 2017-10-20
  • 2019-06-01
  • 1970-01-01
  • 2020-01-24
  • 1970-01-01
相关资源
最近更新 更多