Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I have Ubuntu 10.04 as host machine and Ubuntu 10.10 as guest machine installed in VirtualBox.

I had success on port forwarding to connect to Apache of guest machine, so that now I can open in host machine web sites published in Web Server(Apache) of guest machine.

I need to do the same with MySql, i.e. access MySql of guest machine from host machine.

In order to achieve this goal I am executing following commands in host machine:

VBoxManage setextradata Ubuntu "VBoxInternal/Devices/e1000/0/LUN#0/Config/mysql/HostPort" 3307
VBoxManage setextradata Ubuntu "VBoxInternal/Devices/e1000/0/LUN#0/Config/mysql/GuestPort" 3306
VBoxManage setextradata Ubuntu "VBoxInternal/Devices/e1000/0/LUN#0/Config/mysql/Protocol" TCP

where Ubuntu is the name of the host machine.

Guest machine loads and when I try to connect to MySql from host machine it can not connect to it.

What could be the problem here?

Thank you.

share|improve this question
    
Could you add the MySQL connection settings you're using? So we can help you further. –  Huygens Nov 10 '10 at 19:33
    
"... where Ubuntu is the name of the host machine." Umm, no, you're editing the configuration of the guest machine. This means that your 10.04 mysql client needs to connect to localhost port 3307 to talk to the guest port 3306. –  Steve Beattie Nov 18 '10 at 19:56

2 Answers 2

up vote 8 down vote accepted

Things to check:

  1. What is the "host" field set to for your MySQL user? If it is localhost or similar then the MySQL server is denying access because you are connecting from an external machine. Change the host field to % to allow connections from any IP (though obviously never use this in a production environment where the guest is accepting connections from the Internet)

  2. Is your MySQL server set up to allow remote connections? Open /etc/mysql/my.cnf and verify that your bind-address is set to the private IP of the guest machine. Also, make sure your port setting matches whatever you are trying to connect on.

Beyond that, you'll need to post logs or connection information so that we can take a closer look at the actual problem.

share|improve this answer
    
You are completely right. I havecommented bind-address and also configured mysql database so that to allow connections from any IP. Thank you for proposal. –  Bakhtiyor Dec 2 '10 at 16:50
    
Glad that it ended up getting resolved. Enjoy! –  ayan4m1 Dec 3 '10 at 17:23

Instead of using the port forwarding for each application you can use the 'Bridged networking' for your guest os. So that you can assign an ip with same subnet mask as your host system. For example if your host sytem's ip is 192.168.0.10 ,after enabling the bridged networking you can assign a similar ip to the guest also, say 192.168.1.11. Thus you can access all services running on guest as normal. Read the below link for more info about setting up bridged network. It is an easy task will not take more than 2 minute.

http://www.virtualbox.org/manual/ch06.html

share|improve this answer

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.