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 Heroku

Connect to MySQL on Heroku

Find or Install the Add-On

Heroku does not offer a native MySQL add-on but instead supplies it through a third party, ClearDB. If it has not been added to your application already, you can install it from the Heroku Add-Ons Page. Once installed, it will appear in your Add-Ons list in your Resources tab as ClearDB MySQL.

ClearDB as the MySQL db in Heroku

Get the Username and Password

Click on the link to ClearDB MySQL in the image above and you will be taken to a new tab where you can see the name of your database listed. In this example, the database is called heroku_6f57cf0a7b1288c.

heroku mysql database list

Click on the name of the database and then choose the System Information tab to see the username and password.

Heroku MySQL database credentials

Get the Hostname of the Database

Neither the ClearDB on the Heroku GUIs provide this information. You will need to use the Heroku command line tool to query it. You can find instructions on how to install the CLI here. Once installed, type heroku login to login using the browser. Next enter the following command, using your own app name instead of the one in this example.

heroku config -a arctype-db-test | grep CLEARDB_DATABASE_URL

The database URL string will be printed on the command line. The Hostname is the part after the @ sign and before the /.

get heroku mysql database hostname

Connect to Heroku MySQL

Finally, you can use any SQL client like Arctype to connect. Remember to select SSL because Heroku automatically encrypts connections to your database.

Use a SQL client to connect to Heroku MySQL

Click Test Connection and then Save and you are connected!

Want to ask for help on databases or SQL? Join our Discord community.