简体   繁体   中英

How do I connect to my local MacBook MySQL form Vagrant VM Box?

I've set up Vagrant VM, it's working well for me. Local MySQL is working good too when connection via localhost.

But I can't find a way how to connect via vagrant to macbook local MySQL.

The only visible IP to my vagrant is my local IP address of macbook: 10.0.0.4 It pings it, but this IP is not answering any requests to port 3306, though my.cnf config is set to: bind-address = 0.0.0.0:3306

and Mac firewall switched off for a test.

I'm not sure what info to provide, let me know in comments and I will expand my question.

Thanks a lot

In terms of being able to access the instance of mysql running on your VM's host machine, you can use the ip that vagrant uses for its natted interface.

mysql -uroot -h 10.0.2.2

If you've configured a bridged interface for your vagrant machine then you can use the ip that your host has on the interface that you have bridged to with vagrant.

I've tested this with the brew installed version of mysql and it works when the mysql server on the host is bound on 0.0.0.0 or 127.0.0.1 , ie mysql.server start --bind-address=127.0.0.1

您可以使用以下方法从无业游民的盒子连接到本地mysql

mysql --host=10.0.2.2 -uroot -p

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