Of course there is a way, preferably it is to acquire both machines under the same provider, which are as close as possible to each other and you must configure the connection to the database allowing connections to it (machine 1) from the outside, you must configure a mysql user and a password...