使用mysql Workbench连接到Vagrant Mysql

时间:2014-12-17 08:31:34

标签: mysql vagrant mysql-workbench

我有流浪汉穿过Laravel Homestead。如何创建一个Mysql Workbench连接(Workbench在VM之外)到我的vagrant mysql?我试过了:

SSH上的标准TCP / IP

ssh host: 192.168.10.10 // (same as my Homestead.yaml file)
ssh user: vagrant
ssh password:  // (I've tried blank or vagrant)
ssh key file: ~/.ssh/id_rsa

mysql host: 127.0.0.1
mysql port: 3306
user: root
password: <mypassword>

我已经尝试过我能想到的每一个组合。我错过了什么?我有一个高效的web dev enviro已在本地运行。我想尝试流浪的虚拟服务器。我只是错过了与vagrant的mysql的本地连接。我已经在这3天了。

Vagrantfile:

require 'json'
require 'yaml'

VAGRANTFILE_API_VERSION = "2"

homesteadYamlPath = File.expand_path("~/.homestead/Homestead.yaml")
afterScriptPath = File.expand_path("~/.homestead/after.sh")
aliasesPath = File.expand_path("~/.homestead/aliases")

require_relative 'scripts/homestead.rb'

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
    if File.exists? aliasesPath then
        config.vm.provision "file", source: aliasesPath, destination: "~/.bash_aliases"
    end

    Homestead.configure(config, YAML::load(File.read(homesteadYamlPath)))

    if File.exists? afterScriptPath then
        config.vm.provision "shell", path: afterScriptPath
    end
end

Homestead.yaml:

---
ip: "192.168.10.10"
memory: 2048
cpus: 1

authorize: ~/.ssh/id_rsa.pub

keys:
    - ~/.ssh/id_rsa

folders:
    - map: ~/projects/
      to: /home/vagrant/projects/

sites:
    - map: test1.local
      to: /home/vagrant/projects/test1
    - map: test2.local
      to: /home/vagrant/projects/test2

databases:
    - homestead

variables:
    - key: APP_ENV
      value: local

请注意:

为了让事情顺利进行,我选择通过标准TCP / IP 连接,而不是通过SSH 与Mysql Workbench连接标准TCP / IP 。我使用的设置是:

Hostname: localhost
Port: 33060
Username: homestead
Password: secret

1 个答案:

答案 0 :(得分:6)

向我们展示您的`Vagrantfile,并检查您是否有端口转发,并建议为其设置第二个修复IP。

  config.vm.network "forwarded_port", guest: 3306, host: 3306
  config.vm.network :private_network, ip: "192.168.10.50"

然后在mysql-workbench中,使用端口3306连接到192.168.10.50