Port Forwarding to Connect to MySQL Database of VirtualBox

Solution 1:

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.

Solution 2:

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