Connect to DB through Vagrant using RubyMine

2019-04-09 20:50发布

I just started working on a ruby project which is set up through Vagrant. I've successfully gotten a remote interpreter working but I'm having trouble connecting to databases.

Here's my Vagrantfile:

# This Vagrantfile is for development use only.
VAGRANTFILE_API_VERSION = "2"

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
  config.vm.box = "markusproject/ubuntu"

  # Allow instance to see project folder.
  # Warning: This may cause problems with your Vagrant box!
  #          Enable at your own risk.
  # config.vm.synced_folder ".", "/home/vagrant/Markus"

  # Access the server running on port 3000 on the host on port 42069.
  # config.vm.network "forwarded_port", guest: 3000, host: 42069
  config.vm.network :private_network, ip: '192.168.50.50'
  config.vm.synced_folder '.', '/home/vagrant/Markus', nfs: true

  config.vm.provider "virtualbox" do |vb|
    # Uncomment the following line if you want a GUI.
    # vb.gui = true
    vb.name = "markus"
  end
end

I've set up the VM to use NFS. Here's the output of vagrant ssh-config:

Host default
  HostName 127.0.0.1
  User vagrant
  Port 2222
  UserKnownHostsFile /dev/null
  StrictHostKeyChecking no
  PasswordAuthentication no
  IdentityFile /Users/paymahn/.vagrant.d/insecure_private_key
  IdentitiesOnly yes
  LogLevel FATAL

I've left the defaults for the Database connection but have tried several variations on setting up an SSH Tunnel for the connection.

Database setup tab SSH Tunnel configuration

These variations include:

  1. setting Proxy Host to 127.0.0.1
  2. setting Port to 2222
  3. setting the proxy host to 192.168.50.50
  4. setting Port to 22

All of the variations have resulted in a failed connection when I test the connection. Any help on getting this config set up would be greatly appreciated!

1条回答
何必那么认真
2楼-- · 2019-04-09 21:39

Well...I figured it out thanks to this guy.

Here's how the final dialogs look like: Database tab SSH/SSL tab

I did the exact same thing for the test database except I changed the database name from markus_development to markus_test

查看更多
登录 后发表回答