Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Connect to Host MySQL Server on Vagrant

It's possible to connect to the Host's MySQL Server inside a Vagrant box? I'm running a RoR vagrant box, but I need to connect to the host database server.

Any help?

like image 338
arielcr Avatar asked Feb 06 '14 01:02

arielcr


People also ask

How do I run MySQL on a vagrant server?

* You can enter your MySQL shell by entering mysql -u root -p in your Vagrant shell. Note that I’m allowing the root user to be able to login from any host now. Everything in this post is meant for local development and should NOT be done on a live server.

How do I connect to my MySQL database from the host machine?

This gist shows how to connect to your vagrant MySQL database from the host machine. Change parameter bind-address to 0.0.0.0 to allow all incoming connection attempts On host connect as root user using mysql -uroot -proot Insert GRANT ALL PRIVILEGES ON *.*

How do I forward the default MySQL port in Vagrant?

First thing you need to do is forward the default MySQL port (3306) on your virtual box / Vagrant machine. You can do so by editing your Vagrantfile and add the following code: config.vm.network "forwarded_port", guest: 3306, host: 3306

Why can't I SSH into my vagrant VM?

Make sure you remove any public keys from your host machine's known_hosts file that are for the same host (IP Address). This will have happened if you have been using another Vagrant VM with the same IP address You can also get the SSH config values from the vagrant ssh-config command.


1 Answers

There are two thread one on stack overflow and another on superuser that might help you out with doing this. Links below.

How to connect with host PostgreSQL from vagrant virtualbox machine

https://superuser.com/questions/310697/connect-to-the-host-machine-from-a-virtualbox-guest-os/310745#310745

It is possible to do what you are trying to achieve if you get your settings correct.

like image 173
Jeremy Quinton Avatar answered Oct 07 '22 19:10

Jeremy Quinton