我在 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/