App overview screenshotSQL and Database Guides
Try our free SQL Client
Connecting to MySQL
Connecting to Drivers
Installing MySQL
Setting up MySQL
MySQL   >   
Setting up MySQL   >   
MySQL on Digital Ocean

Connect MySQL and Digital Ocean

How to connect to MySQL on Digital Ocean

If your role is to deploy an application to Digital Ocean, but you don’t know how to connect it to your MySQL database server, then you've come to the right place. This tutorial will walk you through how to connect MySQL to a droplet on Digital Ocean.

Installing MySQL

If you don’t already have MySQL installed on your Digital Ocean droplet, you can do so using the command below:

For Centos:

sudo yum install mysql-server

/etc/init.d/mysqld start

For Ubuntu:

sudo apt-get install mysql-server

Creating a database on digital ocean droplet

To create a database, run the follow the following command in your terminal:

Step 1:

$ CREATE DATABASE database name;

In this tutorial, we will call our database mydata.

Step 2:

Check the database


Resulting databases

The result should look like this.

Step 3:

Access the database. You can do this with the following command:

$USE mydata;

Step 4:

Create a MySQL table with the commands shown below.


name VARCHAR(20),

food VARCHAR(30),

confirmed CHAR(1),

signup_date DATE);

Creating a table

The result should look like this.

Step 5:

Show the MySQL table with the following command.

$ SHOW tables;

Showing a table

The result should look like this.

Connecting to the MySQL database remotely

To connect using the flags format with MySQL using the doadmin user, paste the entire command from the control panel into your terminal:

$mysql -u doadmin -p your_password -h -P 25060 -D defaultdb;

You can also leave the password out when using the above commands, but you will be prompted to enter it before you can connect.

When you successfully connect, the shell displays some information about the MySQL server and your changes. Successful MySQL connections look like this:

Successful connection

Testing Connections using Arctype

To test your connection, input the following information in a SQL client like Arctype

Successful connection

Get help on databases and SQL. Join our Discord community.