PgAdmin on Windows 10 with Postgres when installed via Bash on Ubuntu on Windows

浪子不回头ぞ 提交于 2020-01-03 10:44:22

问题


I would like to install Rails 5/Postgres within Bash On Ubuntu On Windows and also be able to access Postgres database via PgAdmin for Windows.

Am quiet happy to install all my rails dependencies through Bash on Ubuntu on Windows, but I am aware that I can't run any standard GUI tools from Bash and was wondering if it is possible to install Rails and PostGres on the Linux Subsystem and then query my databases using the Windows version of PgAdmin

I had a look at this tutorial how-to-install-ruby-on-rails-on-windows-10-with-postgresql but it seems that he installs Postgres into windows rather then the Linux Subsystem.

I was wondering if this is the only way to go about getting all these tools working nicely together.

Basically I want my Windows installed PgAdmin to communicate to my Bash On Ubuntu On Windows Postgres DB


回答1:


Here's what I did to connect Postgres DB installed in WSL Ubuntu from Windows pgAdmin.

  1. Launch Ubuntu in Windows.
  2. Start postgres in Ubuntu terminal: sudo service postgresql start
  3. Download the latest pgAdmin and install in Windows.
  4. Launch pgAdmin, a new tab in browser opens; click on Add New Server link.
  5. In the popup Create - Server window in the browser:
    1. General tab: I set Name to localhost
    2. Connection tab: I set Host name/address to localhost, set Password to postgres, which is the default, click on Save password?
    3. I save the setting, leaving the rest of the fields as is
  6. That's it, I can see the DB created in Postgres immediately.




回答2:


Ubuntu has X server, where you can run pgAdmin III GUI (I never tried IV, but quite sure it will work on linux even better). Still if you want to setup db on some virtual machine on Windows and use Windows client - yes - it will work. You need to setup some network bridge between your virtual machine and hosting Windows and that is it - use Ubuntu IP to connect to Postgres. (also you will need to allow connections in pg_hba.conf and set listen_address to *, but this needs to be done for external connects anyway)



来源:https://stackoverflow.com/questions/45707319/pgadmin-on-windows-10-with-postgres-when-installed-via-bash-on-ubuntu-on-windows

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!