Cannot communicate between two VM on the same physical machine using NAT IP Addressing

Solution 1:

Both your virtual machines are behind the VirtualBox NAT and are invisible to each other. You'll need to configure the virtual machines to use Bridged networking, so they can obtain an IP on your network.

Solution 2:

Check that

  • Virtual Box allows connections between the two VMs - this seems to be the case already, as you say they can ping each other.
  • the port on the mysql-machine is open by using "telnet mysqlmachine 3306" or "nmap mysqymachine -p 3306" - this will reveal if some firewall blocks access.
  • mysql binds to the public ip address of the machine - As far as I recall it might just bind to localhost, being unavailable from the network (which is a good thing)
  • you've granted the user you're connecting as the correct permissions. This applies also to the naming of the machine you're connecting from. I've learnt that "GRANT ... ON ... TO 'username'@'localhost' ..." might fail if mysql complains with "user 'username' is not allowed to connect from '127.0.0.1'" - in a networked situation you might have similar problems. Note, it's stringcompare there, so 'localhost' does not equal '127.0.0.1'

Edit: Just after posting I've seen that you say that both IP-Addresses are the same. Therefor the root problems seems to be in Virtual Box - check the network configuration there. Each computer will try to contact itself if they both resolve their IP address to themselves.

Once you have different IP-adresses and can ping the other machine, continue with the list above. I have not worked with Hamachi, so I cannot comment on the options you have there... You might want to try the telnet or nmap options with the Hamachi address though.