'How to access external MySQL from within Vagrant?

I would like to access a MySQL database in the public network my host is on. I need to access the MySQL database from within Vagrant by connecting to the DB via PHP's mysql_connect.

I have an ubuntu/trusty64 Vagrant box running Apache2, PHP and MySQL through the old mysql extension.

When I try to connect to the database on the network via the DB server's IP address, it says Can't connect to database.

What do I need to do to be able to access external servers from within the Vagrant guest?



Solution 1:[1]

I could connect properly after all. I just mixed up the variables for my password and the DB name in my code. ^_^;

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 rakista112