Connecting to Compose for MySQL


With Compose for MySQL now available as a beta, you'll be eager to get up and running with it. Here, we'll walk through how to set up a deployment and securely connect to it. We will take you from provisioning your own MySQL database to connecting to it within a few minutes. If you are familiar with Compose's other databases, you'll feel right at home with Compose for MySQL.


Creating a Compose for MySQL deployment follows the same pattern as all other Compose database deployments. Sign in to your Compose account and then, from the Deployments view, click on Create Deployment and select MySQL from the Beta selection of databases.

The Compose system generates a deployment name and selects AWS US-East-1 as the location for the new database deployment. You can change the database name and the data center location; in the latter case selecting from Amazon, Google and SoftLayer data centers around the world. There's also a slider which allows you to select the amount of disk storage your deployment should initially be allocated. You can leave it as is and let Compose's autoscaling system allocate storage as needed, or you can dial in your requirements and configure your deployment with that much space up front. Autoscaling will still work if you manually select your database size. Once the form is filled in, click Create Deployment and Compose will begin provisioning your database. When it's complete you'll see this...

You'll find the information needed to connect to your deployment in the Connection info panel. It contains three things: your credentials, which in this case is the password for the admin user, a Connection string which can be used with database drivers to automatically connect, and a Command line which allows you to manually log in to the database.

Connecting to Your Deployment

Your deployment comes with a "compose" database that's created by default. To connect to Compose for MySQL using the command line, you first have to install MySQL on your machine. Each platform has its own installation packages, so choose the one that's right for you. There's Oracle community packages at Before you download from there, be aware that Linux users will usually find MySQL in their distributions repository. If you're working on a Mac, we recommend you install MySQL using Homebrew using brew install mysql, which will compile and install the latest version of MySQL.

To access your deployment via the terminal, you can copy and paste the command line string provided in the Connection info panel into your terminal to connect to your deployment like:

You can ensure that SSL is used when connecting by using --ssl-mode=REQUIRED. The default user is named "admin" which you use as the username in the -u parameter. After running the command, since the password parameter -p has no value, you'll be prompted to enter the admin user's password, which you can get from the credentials section here:

Compose for MySQL has SSL enabled by default, but when connecting, we suggest you take extra precautions by using the--ssl-mode=REQUIRED option on the command line. This stops MySQL falling back, for whatever reason, to an unencrypted connection. SSL can be disabled by using --ssl-mode=DISABLED if you want to test unencrypted connections.

If you want to verify which host you're connecting to, you can obtain a self-signed certificate for the MySQL server from the Compose web console. You can use this for verification when establishing a connection:

To view the certificate, click on Show certificate. You might be asked for your Compose username and password for re-authentication. Once your password is authenticated, you'll be given a self-signed certificate like this:

To use the certificate, create a new file and copy everything from ---BEGIN CERTIFICATE--- to ---END CERTIFICATE--- and save with the .pem extension. This file is used to verify the certificate that the server presents the MySQL command line tool and ensure that the host you are connecting to is the one you expect. To make use of it, change the --ssl-mode to --ssl-mode=VERIFY_CA and add --ssl-ca with the path and name of your .pem file like this:

When you've successfully logged in, you should get see something similar to this:

Discover Compose for MySQL

Now that we've covered the basics of setting up and connecting to your own MySQL deployment, you have the ability to discover other features of the database and view the benefits of using MySQL on Compose. So, discover what Compose for MySQL can do for you and your organization and tell us what you're building and what you think about it.

Image by valor kopeny
Abdullah Alger
Abdullah Alger is a former University lecturer who likes to dig into code, show people how to use and abuse technology, talk about GIS, and fish when the conditions are right. Coffee is in his DNA. Love this article? Head over to Abdullah Alger’s author page to keep reading.

Conquer the Data Layer

Spend your time developing apps, not managing databases.