delpeter
By:
delpeter

Remotely connecting into MySQL running on an Ubuntu Digital Ocean Node with JMeter locally

April 19, 2016 2k views
MySQL MariaDB DigitalOcean Monitoring Ubuntu

Hi All,

I'm trying to remotely connect to MySQL which has been installed on an Ubuntu VM in Digital Ocean. I have edited the my.cnf file as described on the MariaDB website

bind-address = VM ip address

Ran this command in MySQL within the VM

GRANT ALL PRIVILEGES ON . TO 'root'@'VM IP ADDRESS' IDENTIFIED BY 'MY PASSWORD' WITH GRANT OPTION;

& added the database URL within J-Meter as follows

jdbc:mysql://ipofVM:3306/sakila

However, when I run the JMX file I cannot get a connection to the VM in Digital Ocean

Any suggestions please?

Thanks
Del.

1 Answer

Hi!

GRANT ALL PRIVILEGES ON . TO 'root'@'VM IP ADDRESS' IDENTIFIED BY 'MY PASSWORD' WITH GRANT OPTION;

As you are connecting from your computer, you will need to allow it to connect to MySQL, which means that the command should look like ... 'root'@'1.2.3.4' ... instead, where 1.2.3.4 is your local computer's public IP address.

However, exposing your MySQL server to the public is a bad idea. Instead, configure MySQL to listen on and allow logins from localhost only. Then, use your SSH client to set up an SSH tunnel that forwards port 3306 on your computer to port 3306 on your Droplet. As you're connecting via the tunnel, the connections appear to MySQL as if they're coming from inside the Droplet itself.

Once you've done that, you should be able to have JMeter connect to MySQL at localhost:3306 and the connection will be tunneled to your Droplet, allowing you to securely access your MySQL server from your computer.

In this article, you'll learn how to create a safe, encrypted tunnel between your computer and your VPS along with how to bypass limits in a corporate network, how to bypass NAT, etc.
  • Hi Kamain,

    Thanks for the reply!

    Oh so I don't put the VM ip address but my host ip address where I am using the J-Meter application i.e. my Asus laptop? It is my understanding that I put the VM ip address into the Database URL, MySQL is installed on a droplet.

    I dont mind about MySQL server to the public, this is just for testing purposes comparing MySQL in a VM towards a Docker container :)

    Del.

    • If you do not want to use an SSH tunnel, you will need to put the Droplet's IP address and allow access from your computer by running the following SQL command:

      GRANT ALL PRIVILEGES ON . TO 'root'@'your computer's public IP address' IDENTIFIED BY 'MY PASSWORD' WITH GRANT OPTION;
      

      Otherwise, since the connection is going through the tunnel, you will need to use localhost (as is) or simply 127.0.0.1.

Have another answer? Share your knowledge.