How do you connect a web droplet to a different MySQL database droplet?

December 27, 2014 2.6k views

I have two droplets. One is our website droplet and the second is the MySQL database droplet. Using the website droplet console I am trying to test the connection to the MySQL database droplet. I type mysql -u root -h hostname -p. I got an error message "Access denied for user root@vital-c.net (using password: YES).

Any advice?????

2 comments
  • probably you need to enable connecting from a different host.

    On your MySQL droplet, if you have phpmyadmin, you go to Users and create a user that will specifically be for connecting from that web-server Droplet.

    There will be a section for "Host" where you can put your web-server droplet IP. After you create that user, you may need to edit the privileges and give that user permissions on whatever databases you need.

    So basically, you are telling MySQL that this new user has permissions to connect to whatever database from a different host (IP Address) than localhost (the default).

  • In additon to @sierracircle's suggestion, you might also want to check out the tutorial "How To Set Up a Remote Database to Optimize Site Performance with MySQL." While it uses WordPress as the example, it should point you in the right direction for setting up a MySql server to be connected to remotely even if you are using something else.

    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.
1 Answer

This question was answered by @asb:

In additon to @sierracircle's suggestion, you might also want to check out the tutorial "How To Set Up a Remote Database to Optimize Site Performance with MySQL." While it uses WordPress as the example, it should point you in the right direction for setting up a MySql server to be connected to remotely even if you are using something else.

View the original comment

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.
Have another answer? Share your knowledge.