Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have VirtualBox running Ubuntu on my Windows 7 computer.

Is it possible for me to connect to the MySQL server running on the VM from my Windows 7 host?

share|improve this question

migrated from stackoverflow.com Jul 28 '10 at 21:05

This question came from our site for professional and enthusiast programmers.

add comment

2 Answers

You can enable NAT on the virtual machine so that it's IP address is available on windows.

Another option is to enable port forwarding on the "Guest" machine, so that it is accessible on the "Host" machine as 127.0.0.1, this way you can just connect to localhost:3306.

I would suggest not doing option #2 if you are into having mysql on both your host and the guest.

share|improve this answer
add comment

If you give the virtual machine its own IP address - check out :

http://www.virtualbox.org/wiki/Advanced_Networking_Linux

The virtual machine may be fully integrated into the network and you may have access between all virtual machine and the host if you do a little bit more.

A bridge can contain only one physical/virtual device. So you can create your bridge as follow:

#!/bin/sh
# set PATH for the case we are called via sudo or su root

PATH=/sbin:/usr/bin:/bin:/usr/bin

# create a tap
tunctl -t tap1 -u <user>
ip link set up dev tap1
f
# create the bridge
brctl addbr br0
brctl addif br0 tap1

# set the IP address and routing
ip link set up dev br0
ip addr add 10.1.1.1/24 dev br0
ip route add 10.1.1.0/24 dev br0

With this code you will be able to contact the virtual machine attached to the Host Interface tap1 from the host and the host from the virtual machine. The IP adress should not conflict with the main IP address of your PC which will probably been within the range 192.168.0.0/16.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.