MySQL on a separate droplet

March 6, 2014 7.1k views
Hello, I currently have one droplet with ubuntu/lamp. In order to scale horizontally I would like to put MySQL on a dedicated droplet. But I could not figure out where to start and how to secure the communication between the two droplets (ssh tunneling, vpn, ...) while allowing communication between php on one side and MySQL on the other. If someone have any guidance on this it would be great :) Thanks!
5 Answers
Follow on a new droplet and then secure it by configuring mysql to listen on the private network interface by editing /etc/mysql/my.cnf and setting bind-address to your private IP address. Finally, install a firewall on your droplet so that only your app server can connect to your MySQL server:
by Shaun Lewis
Learn how to setup a firewall with UFW on an Ubuntu / Debian cloud server.
I did this using CentOS. Basic workflow:

1) Create droplet, preferably in the same private network as your web server
2) Configure firewall (on db server) to close ALL ports, then open port 3306 to allow database traffic ONLY from your web server's private IP address. You will also need to open port 22 so you can SSH in. Can also restrict which IP you can SSH in from, essentially creating a tunnel to your db server via your web server (or whatever other IP you want to use).
3) Install MySQL and set up users

Here's what I did:

404 not found :D
@kurniawanmagelang it's without www

Not working, got 404 error when run mysql with different droplets.

Have another answer? Share your knowledge.