How To Set Up MySQL on DigitalOcean
Tags: mysql, database, digitalocean, cloud
Published: 2021-02-05 22:59:58

---
title: How To Set Up MySQL on DigitalOcean
published: true
description: With just a few simple steps, you can set up a fully managed MySQL database on DigitalOcean for the best possible performance. This tutorial explains how.
tags: mysql, database, digitalocean, cloud
cover_image: https://scalegrid.io/blog/wp-content/uploads/2021/01/How-to-Set-Up-MySQL-on-DigitalOcean.jpg
---
<link rel="canonical" href="https://scalegrid.io/blog/how-to-set-up-mysql-digitalocean/" />
<p style="text-align: justify;">MySQL is the number one open source relational database management system in the world, and is used by millions of developers across all application types. DigitalOcean, a fast-growing cloud provider that’s increasing in popularity amongst the developer community, is a great host to consider for your MySQL deployments. In this article, we’re going to show you <a style="color: #2da964;" href="https://scalegrid.io/blog/how-to-set-up-mysql-digitalocean/">how to set up MySQL on DigitalOcean</a> at ScaleGrid for the best possible performance in the cloud.</p>

<h2>Building Your DigitalOcean MySQL Deployment</h2>
<p style="text-align: justify;">For this tutorial, we are using our fully managed <a style="color: #2da964;" href="https://scalegrid.io/mysql.html">MySQL hosting</a> solution, as it offers the highest throughput and lowest latency on DigitalOcean. Learn more in the <a style="color: #2da964;" href="https://scalegrid.io/blog/best-mysql-digitalocean-performance-scalegrid-vs-digitalocean-managed-databases/">Best MySQL DigitalOcean Performance</a> article to compare ScaleGrid vs. DigitalOcean Managed Databases pricing, latency and throughput performance.</p>
<p style="text-align: justify;">The entire process should take less than 20 minutes, with just a couple minutes at the beginning to customize your MySQL deployment configuration, and a couple minutes at the end to connect to your application.</p>
<p style="text-align: justify;">Video Tutorial: <a style="color: #2da964;" href="https://www.youtube.com/watch?v=ywBy-w0KiN0">https://www.youtube.com/watch?v=ywBy-w0KiN0</a></p>
<p style="text-align: justify;">After signing up for a free <a style="color: #2da964;" href="https://console.scalegrid.io/users/register">trial account</a>, the first thing you’ll do is select MySQL as your database, DigitalOcean as your cloud, and Dedicated Hosting as your plan to initiate the cluster creation process:</p>

<h3>Step 1. Enter MySQL Deployment Details</h3>
<p style="text-align: justify;">The <a style="color: #2da964;" href="https://help.scalegrid.io/docs/mysql-new-cluster-dedicated-hosting">cluster creation</a> wizard will open to the first step where you can customize the basic details of your deployment. Enter a name for your cluster using alphanumerics, and use a unique, descriptive name so you can easily recognize your cluster later on.</p>
<p style="text-align: justify;">Next, select the DigitalOcean data center you’d like to use for your master server from the cloud region dropdown - we recommend using the same region as your applications DigitalOcean Droplets for the best performance. Then you can select your VM size of DigitalOcean Droplet instances, and the version of MySQL you wish to use (all major versions supported). InnoDB Storage Engine is the default for all MySQL deployments. Click next.</p>
<p style="text-align: justify;"><a href="https://scalegrid.io/blog/how-to-set-up-mysql-digitalocean/"><img class="alignnone size-full wp-image-6148" src="https://scalegrid.io/blog/wp-content/uploads/2021/01/Create-MySQL-on-DigitalOcean-Step-1.png" alt="Create MySQL on DigitalOcean - Step 1" width="100%" height="auto"/></a></p>

<h3>Step 2. Enable Master-Slave Replication</h3>
<p style="text-align: justify;">In step 2, you can enable DigitalOcean MySQL master-slave replication to add high availability to your deployment. Replication is important for keeping your application available and online for your users in the event your DigitalOcean data center region goes down. While DigitalOcean is a highly reliable cloud provider with 99.99% uptime, data centers inevitably go down, so replicating your data to additional data center locations allows you to minimize the risk of data loss and downtime for your users.</p>
<p style="text-align: justify;">If you want to continue with a standalone deployment, click next to move onto step 3 without enabling master-slave configuration.</p>
<p style="text-align: justify;">Note - master-slave configuration is only available for paid accounts, you cannot set up a replica set deployment while you are in trial mode.</p>
<p style="text-align: justify;">There are a couple options here to customize your MySQL master-slave setup. First, you can choose between 2 + 1 Quorum or 3 nodes for your deployment. Both offer high availability, but in the 2 + 1 Quorum setup, you have only 2 data-bearing nodes as the Quorum node serves as a decision-maker in a failover event. You can also contact <a style="color: #2da964;" href="mailto:support@scalegrid.io">support</a> to customize your master-slave configuration to add more nodes to your deployment.</p>
<p style="text-align: justify;">Next, you can choose between semisynchronous and asynchronous replication. <a style="color: #2da964;" href="https://scalegrid.io/blog/data-integrity-and-performance-considerations-in-mysql-semisynchronous-replication/">Semisynchronous replication</a> guarantees at least one slave has received all the data that the master has committed, ensuring that the failover to the right slave is lossless. In asynchronous replication, each slave syncs asynchronously to the master so failover from master to slave may result in failover to a server that is not fully synced up to the current master.</p>
<p style="text-align: justify;">Lastly, customize the DigitalOcean data center locations you wish to use for your slave nodes. Once you’re done, click next.</p>
<p style="text-align: justify;"><a href="https://scalegrid.io/blog/how-to-set-up-mysql-digitalocean/"><img class="alignnone size-full wp-image-6149" src="https://scalegrid.io/blog/wp-content/uploads/2021/01/Create-MySQL-on-DigitalOcean-Step-2.png" alt="Create MySQL on DigitalOcean - Step 2" width="100%" height="auto" /></a></p>

<h3>Step 3. Enable SSL</h3>
<p style="text-align: justify;">In step 3, you can enable SSL for your deployment. By default, MySQL server always installs and enables SSL configuration, but it’s not enforced that clients connect using SSL. Clients can choose to connect with or without SSL as the server allows both types of connections. Learn more about configuring and managing SSL in this <a style="color: #2da964;" href="https://scalegrid.io/blog/configuring-and-managing-ssl-on-your-mysql-server/">MySQL tutorial</a>.</p>
<p style="text-align: justify;"><a href="https://scalegrid.io/blog/how-to-set-up-mysql-digitalocean/"><img class="alignnone size-full wp-image-6150" src="https://scalegrid.io/blog/wp-content/uploads/2021/01/Create-MySQL-on-DigitalOcean-Step-3.png" alt="Create MySQL on DigitalOcean - Step 3" width="100%" height="auto" /></a></p>

<h3>Step 4. Configure Firewalls</h3>
<p style="text-align: justify;">In the last step of the cluster creation process, enter at least one IP CIDR that will be allowed access to your MySQL deployment to set up your firewall rule. You can find your current IP CIDR at the top of the page. These can be customized later at both the cluster-level and account-level. Once you’ve entered it, click Add. Enter all the IP CIDRs you’d like, and then click next.</p>
<p style="text-align: justify;"><a href="https://scalegrid.io/blog/how-to-set-up-mysql-digitalocean/"><img class="alignnone size-full wp-image-6151" src="https://scalegrid.io/blog/wp-content/uploads/2021/01/Create-MySQL-on-DigitalOcean-Step-4.png" alt="Create MySQL on DigitalOcean - Step 4" width="100%" height="auto" /></a></p>

<h3>Step 5. Review &amp; Create</h3>
<p style="text-align: justify;">The last page provides a short summary of your new MySQL DigitalOcean cluster. Review all of the details and click the Previous button to go back to an earlier step and modify your configurations. Once you’re ready, click Create to spin up your cluster.</p>
<p style="text-align: justify;"><a href="https://scalegrid.io/blog/how-to-set-up-mysql-digitalocean/"><img class="alignnone size-full wp-image-6152" src="https://scalegrid.io/blog/wp-content/uploads/2021/01/Create-MySQL-on-DigitalOcean-Step-5.png" alt="Create MySQL on DigitalOcean - Step 5" width="100%" height="auto" /></a></p>
<p style="text-align: justify;">And that’s it! Your deployment is now being provisioned! This takes about 15 minutes, so while you wait, you can familiarize yourself with the management tools for MySQL in the console - <a style="color: #2da964;" href="https://help.scalegrid.io/docs/mysql-backups">backups</a>, <a style="color: #2da964;" href="https://help.scalegrid.io/docs/mysql-backups-restores">restores</a>, <a style="color: #2da964;" href="https://help.scalegrid.io/docs/mysql-dynamic-scaling">scaling</a>, <a style="color: #2da964;" href="https://help.scalegrid.io/docs/mysql-alerts-rules">alerts</a>, <a style="color: #2da964;" href="https://help.scalegrid.io/docs/mysql-monitoring-slow-query-analyzer">query analysis</a>, etc.</p>

<h2>Connect &amp; Migrate</h2>
<p style="text-align: justify;">Once the cluster status changes from “Creating” to “Running”, you can <a style="color: #2da964;" href="https://help.scalegrid.io/docs/mysql-connecting-to">connect your deployment</a>. There are a couple different ways to do this - through your <a style="color: #2da964;" href="https://help.scalegrid.io/docs/mysql-connecting-to-your-application">connection string</a> to your app, through the <a style="color: #2da964;" href="https://help.scalegrid.io/docs/mysql-command-line-syntax">command line</a>, through <a style="color: #2da964;" href="https://help.scalegrid.io/docs/mysql-connecting-wordpress">WordPress</a>, through <a style="color: #2da964;" href="https://help.scalegrid.io/docs/mysql-connecting-to-mysql-workbench-gui-tool">MySQL Workbench</a> or other popular <a style="color: #2da964;" href="https://help.scalegrid.io/docs/mysql-connecting-to-gui">GUI tools</a>. All of your connection details are available in the lower half of the Overview tab of your cluster details page.</p>
<p style="text-align: justify;">Visit the top tabs to <a style="color: #2da964;" href="https://help.scalegrid.io/docs/mysql-create-database">create a MySQL database</a> and <a style="color: #2da964;" href="https://help.scalegrid.io/docs/mysql-create-database-user">create a MySQL database user</a>. These can be accessed and managed anytime from the ScaleGrid console.</p>
<p style="text-align: justify;"><a href="https://scalegrid.io/blog/how-to-set-up-mysql-digitalocean/"><img class="alignnone size-full wp-image-6153" src="https://scalegrid.io/blog/wp-content/uploads/2021/01/MySQL-DigitalOcean-Console-ScaleGrid.jpg" alt="MySQL DigitalOcean Console at ScaleGrid DBaaS" width="100%" height="auto" /></a></p>
<p style="text-align: justify;">Migrating is also an automated process that requires just a few details from your existing deployment. Click the Import Data button on your Overview tab, and enter your Server Name, Port, Database Name(s), Username and Password. Check out our <a style="color: #2da964;" href="https://help.scalegrid.io/docs/mysql-migrations">MySQL Migrations</a> doc for more detail, and additional migration options.</p>

<h2>Running on DigitalOcean</h2>
<p style="text-align: justify;">Once you’re up and running, your deployment can virtually operate on auto-pilot. Since ScaleGrid is a fully managed service, we handle all of your day-to-day MySQL administration and maintenance so you can focus on building your app. If anything should arise that requires your attention, such as running low on disk space, we’ll send you a notification so you can login and see if you’re ready to scale up your cluster.</p>
<p style="text-align: justify;">You can also connect with our MySQL experts anytime through our 24/7 support to help you set up and troubleshoot your deployment.</p>