Scale up as you grow — whether you're running one virtual machine or ten thousand.

From GPU-powered inference and Kubernetes to managed databases and storage, get everything you need to build, scale, and deploy intelligent applications.

This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
Thank you for this tutorial, it’s exactly what I was looking for to get into the subject!
Curently, I’ve tested this between two droplets acting with the private networking addresses, so in Wordpress’ setup, I’ve entered the private IP of the mySQL droplets.
But is there any negative point in using an IP in Wordpress (or actually, any apps for that matter) rather than a properly formed URL? My guess is that there is actually nothing wrong with it (or nothing could go wrong with it!), but I just want to make sure ! :)
@Jean-Philippe: Nope, nothing wrong with that at all. The main reason that we use domain names to access web sites instead of IP addresses is that we humans have a much harder time remembering strings of numbers rather than a nicely formated name! One other thing that domains names allow is having a stable identifier if the IP address behind it changes. So just remember to change the references to the IP address if you spin up a new database server with a different IP.
Why not just create a hosts file entry for the database IP so that can be referenced and/or updated if needed in one spot?
@AndrewSB thanks for that. I realized soon after that my concerns where out of this world. I had my first thought early in the morning thinking about search engines, can’t really figure why I associated adresses that are only seen by PHP and that. Well all have thoses moments I guess ;-)
One issue I see here is that you are relying solely on MySQL to handle authentication with @webserver_IP. This exposes MySQL to the world still, and allows brute-force attacks on the MySQL port. This will mostly fail, but regardless it is open to attack.
There are two ways to secure this properly.
Use a firewall to ensure port 3306 is exposed to only the web server IP. Install the likes of CSF on your server, or use your cloud providers Access & Security provisions if available to enforce this.
Have MySQL listen only on 127.0.0.1 and have the web server create a VPN or SSH tunnel to the database server so that it can access MySQL locally via the tunnel.
I’ve thought about trying this but was concerned about the latency of having the database on another server. I imagine the effect is pretty small if both servers are in the same data center. But what if they’re in different data centers? Would the latency be an continuous issue for every read / write?
I used this to install opencart, everything worked fine then i shut both droplets down to make a backup and when i restarted them the site would no longer open. Apache error logs from webserver below
In my testing, doesn’t the bind-address have to be set to 0.0.0.0 to access both from the local machine and the remote machine? I had trouble restarting mysql after changing to only the public ip and couldn’t connect to it. Researching the issue, seemed the common suggestion was to use 0.0.0.0. Or am I missing something?
@neil: You can set bind-address to 0.0.0.0 but that means it will listen on all network interfaces including the public interface. It’s recommended that you keep it listening on the private interface and configuring the mysql client to connect to the private IP instead of 127.0.0.1.
You can do that by passing -h 1.2.3.4 to the mysql command where 1.2.3.4 is your droplet’s private IP address, or by adding the following to ~/.my.cnf:
[client]
host=1.2.3.4
YOU’RE A GENIUS and I LOVE YOU!!! thank you thank spank you.
Now, I was getting that whole not being able to restart my mysql with the ip address I was putting in. I have no idea with what you meant bypassing in the -h 1.2.3.4 thing into mysql. Can you clear that up a little for example… should we put the binder back to 121.0.0.1 and then just put host=1.2.3.4 underneath the client like you show above?
Also, to the magic of what we installed that allows us to client tools for mysql… what are those client tools and how can we read more up on them… do they have a specific name?
****Lastly, and probably most importantly… What if we are running a virtual machine farm for the cores of our sites… an availability set… Each vm would have it’s own IP… so how do we bind multiple ip’s for the mysql to listen to? and furthermore we would need to only use one ip for the username as well. is this correct? what can be done in this regard?