1

I struggle connecting from host machine to a MySQL server running inside a Vagrant instance. My small Vagrantfile is:

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
  config.ssh.shell = "bash -c 'BASH_ENV=/etc/profile exec bash'"
  config.vm.box = "debian/wheezy64"
  config.vm.provision :shell, path: "misc/bootstrap.sh"
  config.vm.network "forwarded_port", guest: 80, host: 8082
  config.vm.network "forwarded_port", guest: 3360, host: 33600
  config.vm.network "private_network", ip: "192.168.33.22"

  config.vm.synced_folder ".", "/var/www/",
    owner: "vagrant",
    group: "www-data",
    mount_options: ["dmode=775,fmode=664"],
    create: true

  config.vm.provider "virtualbox" do |vb|
      vb.memory = 1536
      vb.cpus = 1
  end
end

So then I tried to connect from host to MySQL like this:

mysql -h 192.168.33.22 -P 33600 -uroot -proot

And get the following error:

ERROR 2013 (HY000): Lost connection to MySQL server at 'reading initial communication packet', system error: 0

Things I tried to solve the problem:

  • Add mysqld: ALL to hosts.allow
  • Checked hosts.deny for any entry (is completely empty)
  • comment the line bind-address in /etc/mysql/my.conf
  • did GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' WITH GRANT OPTION; and restarted mysql service

some more information:

  • never played around with iptables nor blocked any port
  • connecting from inside vagrant works like charm
  • just this vagrant instance is running
  • running Debian 8
Frederic Henri
  • 51,761
  • 10
  • 113
  • 139
Bene
  • 1,251
  • 6
  • 19
  • 34

0 Answers0