Report this

What is the reason for this report?

MySQL on a separate droplet

Posted on March 6, 2014
team

By team

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!



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!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Follow <a href=“https://www.digitalocean.com/community/articles/how-to-secure-mysql-and-mariadb-databases-in-a-linux-vps”>https://www.digitalocean.com/community/articles/how-to-secure-mysql-and-mariadb-databases-in-a-linux-vps</a> on a new droplet and then secure it by configuring mysql to listen on the private network interface by editing <code>/etc/mysql/my.cnf</code> 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: <a href=“https://www.digitalocean.com/community/articles/how-to-setup-a-firewall-with-ufw-on-an-ubuntu-and-debian-cloud-server”>https://www.digitalocean.com/community/articles/how-to-setup-a-firewall-with-ufw-on-an-ubuntu-and-debian-cloud-server</a>.

I did this using CentOS. Basic workflow: <br> <br>1) Create droplet, preferably in the same private network as your web server <br>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). <br>3) Install MySQL and set up users <br> <br>Here’s what I did: <br>http://jessesnet.com/development-notes/2014/centos-mysql-vps-setup/

The developer cloud

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

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.