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.

  • Could you add the MySQL connection settings you're using? So we can help you further.
    – Huygens
    Nov 10, 2010 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. Nov 18, 2010 at 19:56

2 Answers 2


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.

  • 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, 2010 at 16:50
  • Glad that it ended up getting resolved. Enjoy!
    – ayan4m1
    Dec 3, 2010 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 ,after enabling the bridged networking you can assign a similar ip to the guest also, say 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.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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