我的Vagrantfile中有两台机器:
Vagrant.configure("2") do |config|
config.vm.define "mysql" do |mysql|
mysql.vm.box = "bento/ubuntu-16.04"
mysql.vm.network "private_network", ip: "99.0.33.20"
mysql.vm.provision "shell", inline: ". /vagrant/scripts/vagrant_mysql.sh"
end
config.vm.define "web" do |web|
web.vm.box = "bento/ubuntu-16.04"
web.vm.network "forwarded_port", guest: 80, host: 8080, host_ip: "127.0.0.1"
web.vm.network "private_network", ip: "99.0.33.10"
web.vm.provision "setup",
type: "shell",
inline: ". /vagrant/scripts/vagrant_web.sh"
end
end
我希望能够从web
连接到mysql
,但这是行不通的。在mysql
框中,我可以使用mysql -uroot -p
,它连接良好。但是,无法从网络框中使用mysql -h99.0.33.20 -uroot -p
。 nmap
端口3306显示其已关闭。两台计算机上均未启用ufw
。
vagrant@vagrant:~$ netstat -nr
Kernel IP routing table
Destination Gateway Genmask Flags MSS Window irtt Iface
0.0.0.0 10.0.2.2 0.0.0.0 UG 0 0 0 eth0
10.0.2.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
99.0.33.0 0.0.0.0 255.255.255.0 U 0 0 0 eth1
vagrant@vagrant:~$ ifconfig eth1
eth1 Link encap:Ethernet HWaddr []
inet addr:99.0.33.10 Bcast:99.0.33.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:86 errors:0 dropped:0 overruns:0 frame:0
TX packets:48 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:21752 (21.7 KB) TX bytes:3410 (3.4 KB)
如何找出问题所在?
答案 0 :(得分:0)
将bind-address
中的/etc/mysql/mysql.conf.d/mysqld.cnf
从127.0.0.1
更改为0.0.0.0
。