linux - 无法连接到在 Windows 10 虚拟机中运行的 postgresql 服务器
问题描述
我正在我的 pop-os 笔记本电脑上的 Windows 10 虚拟机中运行 postgres 服务器。我正在尝试从我的主机操作系统(linux)连接到它。在虚拟框中,我创建了一个端口转发规则:
我还将 postgres 配置中的侦听端口更改为等于“*”。
我尝试连接的错误消息是这样的:
postgres@pop-os:/home/peyton$ psql -p 5432
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"?
我不太了解这一点,所以我真的可以使用一些帮助。
谢谢。
解决方案
问题是:
psql -p 5432
是说连接到Linux机器上的本地套接字。根据错误消息:
Is the server running locally and accepting
connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?
您需要执行以下操作:
psql -p 5432 -h 127.0.0.1
推荐阅读
- visual-studio-code - 当子句映射
在 VSCode 中暂存文件 - hyperledger - 如何以单个组织应用程序的参与者身份访问您的作曲家应用程序?
- apache-spark - 如何在 Apache spark SQL 中计算不同的工作
- for-loop - 迭代删除特定类型的文件
- css - 我在修改 React 项目中 svg 组件的一些属性值时遇到问题
- php - 为什么 has_term 不适用于 AND 运算符?
- electron - Electron,窗口属于托盘。我不希望它显示在停靠栏中
- javascript - 如何更改 OpenLayers 5.3 的平铺语言
- java - 我应该为 List > 类型的参数设置什么值?
- c++ - 在命名空间内的类中使用带有运算符重载的字符串流时“不匹配'运算符>>'”