简体   繁体   中英

Connect to Vagrant Mysql with mysql Workbench

I have vagrant running through Laravel Homestead. How can I create a Mysql Workbench connection (Workbench is outside the VM) to my vagrant mysql? I've tried:

Standard TCP/IP over SSH

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>

I've tried every combination I can fathom. What am I missing? I have an efficient web dev enviro already running locally. I wanted to attempt vagrant virtual server. I'm just missing a local connection to vagrant's mysql. I've been on this for 3 days.

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

Please Note:

To get things working, I chose to connect by Standard TCP/IP instead of Standard TCP/IP over SSH with Mysql Workbench. The settings I use are:

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

Show us your `Vagrantfile, and check if you have port forwarding, and recommend to set a second fix IP for it.

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

Then in mysql-workbench, connect to 192.168.10.50 with port 3306

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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