【问题标题】:Connect to Vagrant Mysql with mysql Workbench使用 mysql Workbench 连接到 Vagrant Mysql
【发布时间】:2015-02-15 17:50:25
【问题描述】:

我有流浪者在 Laravel Homestead 中奔跑。如何创建与我的 vagrant mysql 的 Mysql Workbench 连接(Workbench 在 VM 之外)?我试过了:

基于 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 开发环境。我想尝试 vagrant 虚拟服务器。我只是缺少到 vagrant 的 mysql 的本地连接。我已经用了 3 天了。

流浪文件:

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

请注意:

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

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

【问题讨论】:

  • mysql-workbench 在你的虚拟机之外?您是否在 Vagrantfile 中设置了端口转发选项?
  • 是的。工作台在我的虚拟机之外。我找到了一个解决方案,它列在我问题的“请注意”部分。我会尝试发布一个视频教程。感谢您的提问。我会回复您有关端口转发的更多信息,因为我不确定,因为我目前手头没有环境。

标签: mysql vagrant mysql-workbench


【解决方案1】:

向我们展示您的`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

【讨论】:

    猜你喜欢
    • 2017-07-06
    • 1970-01-01
    • 2018-03-29
    • 1970-01-01
    • 1970-01-01
    • 2015-11-29
    • 2016-10-13
    • 1970-01-01
    • 2013-11-03
    相关资源
    最近更新 更多