configuring remote database on nginx/mysql

Posted March 9, 2016 21.8k views
Server OptimizationLoad BalancingLEMP

I’ve been reading this awesome article and thinking to implement for my next project.

but before that, i have few questions that needed to be clear first,

Q1. im going to connect database server & web server through private networking, so how can i connect remotely to my database server? can i connect via remote databse software as im not that familiar on working with ssh tunnel. and for that if i open a port for my database server, does it compromise security too much?

Q1. if above is not possible, i would like to install phpmyadmin on database server, and for that i need to have nginx & php installed on database server. will it make and performance drop? between 2 servers?

i have also asked same questions on that above link but nobody replied. hope someone will reply me here.

Thanks in advance.

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.

Submit an Answer
1 answer

Hey there,

You can certainly setup MySQL on its own Droplet and setup another Droplet to access it over private networking. Please keep in mind that in order to use private networking between two Droplets, you will need to have both Droplets in the same region. For more information on setting up remote access, have a look at the following article:

Mike C
Platform Support Specialist
DigitalOcean Support

by Justin Ellingwood
When your site begins to get more visitors, you may have to think about how to handle the additional traffic. One easy way of doing this is to separate your database operations from your web server so that each can handle its own load. In this guide, we'll demonstrate how to do this for a WordPress site built on Nginx by configuring a remote MySQL database.
  • Hi there,

    I’ve the same exactly similar issue., I’ve done:

    • enable private IP
    • bind address chg to
    • grant access to a specific user with below command GRANT ALL PRIVILEGES ON db_name. to username@private_ip identified by ‘password’;*

    But still cant access with this error:
    mysqli::mysqli(): (HY000/1130): Host 'private_ip’ is not allowed to connect to this MySQL server

    netstat -plant|grep “:3306”|grep “LISTEN” result:
    tcp 0 0 LISTEN 15647/mysqld*

    I'ml new to system administrator, please help.

    • Hey there,

      My apologies for the late reply. After you ran the GRANT ALL PRIVILEGES command, did you also run FLUSH PRIVILEGES to ensure the new privileges would take effect?

      Mike C
      Platform Support Specialist
      DigitalOcean Support
      Check out our fantastic community articles!