我很难从主机连接到在Vagrant实例中运行的MySQL服务器。我的小Vagrantfile是:
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
然后我尝试从主机连接到MySQL,如下所示:
mysql -h 192.168.33.22 -P 33600 -uroot -proot
并收到以下错误:
ERROR 2013(HY000):在“读取初始通信数据包”时与MySQL服务器的连接丢失,系统错误:0
我试图解决问题的事情:
mysqld: ALL
添加到hosts.allow bind-address
行
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' WITH GRANT OPTION;
并重新启动了mysql服务更多信息: