繁体   English   中英

pgAdmin4 + WSL2:看不到使用其他客户端创建的数据库

[英]pgAdmin4 + WSL2: can't see dbs created with other client

我已按照此处的步骤进行操作。 我在 Windows 上成功安装了 WSL2 中的 postgres@12.8 和 PGAdmin4。 一旦我在 WSL 中启动服务并在 pgAdmin 中创建服务器连接,我就看不到从 pgAdmin GUI 创建的任何数据库,也看不到从 psql 客户端创建的任何数据库。

我尝试过了:

  • 将环境变量PGHOST设置为localhost
  • 编辑postgresql.conflisten_addresses = 'localhost'
  • 通过localhost名称和 IP 127.0.0.1连接 pgAdmin 服务器

没有任何作用..

我刚刚遇到了同样的问题。

If you try to access your DB installed with pgAdmin from WSL 2, make sure you didnt install postgreSQL from Windows, as sudo service postgresql start from WSL will also start the only postgresql service you need.

基本上,这意味着您需要安装 postgresql ( sudo apt-get install postgresql )并从 WSL启动它,然后从 ZAEA23489CE3AA9B6406EBB28E0CDA43Z 中打开 pgAdmin。 Do NOT install postgresql directly on Windows as then your pgAdmin might create your DBs into the postgresql service started in Windows and not from the one started from WSL.

还要确保为您的 WSL 2 使用的同一用户安装 pgAdmin,例如,如果您从 VSCode 使用它。 否则,同样的原因,你的 WSL 可能找不到对应的 DB。

请注意,您可以通过从 WSL 运行psql -p 5432 -l来列出特定端口上存在的数据库(将 5432 更改为您要使用的端口)。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM