Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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
like image 427
George Avatar asked Dec 17 '14 08:12

George


People also ask

How do I connect to a local MySQL server in MySQL workbench Ubuntu?

Connecting MySQL Workbench to your server Open up the MySQL Workbench app and then click Database > Connect to database. In the resulting window (Figure 2), fill out the details for your connection. Figure 2: Connecting to a remote server with MySQL Workbench. Click OK and you will prompted for the MySQL user password.


1 Answers

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

like image 57
BMW Avatar answered Sep 21 '22 04:09

BMW