[RAILS] I want to connect to Heroku MySQL from a client

Thing you want to do

I want to connect to MySQL attached to the Heroku app from a client such as MySQL Workbench


Get information

Get the app name

Get the name of the application you are deploying to heroku. In this case, it is assumed that you have deployed an app called hogehoge. The app name of heroku may be special so that it will not be forgotten or covered, so get it with cli and copy it.

$ heroku list

Get app information

Get information about the application hogehoge. The environment variables set in the application are output. In most cases where MySQL is attached to an application on Heroku, the DATABASE_URL should look like this:

$ heroku config -a hogehoge
=== hogehoge Config Vars
CLEARDB_DATABASE_URL: mysql://fizz:[email protected]/heroku_barbarbar?reconnect=true
DATABASE_URL: mysql://fizz:[email protected]/heroku_barbarbar?reconnect=true
The following is omitted

Excerpt from MySQL connection information

You can read all of the connection information from the value of the environment variable.

//If the original is below
mysql://fizz:[email protected]/heroku_barbarbar?reconnect=true

//Read like this
mysql://username:[email protected]/schema?reconnect=true

//That is, it becomes as follows
MySQL host
=> foo.cleardb.com

DB Schema
=> heroku_barbarbar

=> fizz

=> buzz

That's it. All you have to do is enter the information into your client and connect.


Heroku's default database is PostgreSQL, You can also switch to MySQL. In my case, I often use MySQL regardless of work, private, development environment, or production environment, so I changed from Postgres to MySQL.

If you search for how to change it, you will get as many hits as you want, so go there. By the way, the speed is slow when I access it from the client and use it. Well, it's free, so it can't be helped.

Recommended Posts

I want to connect to Heroku MySQL from a client
Connect to Aurora (MySQL) from a Java application
I want to develop a web application!
I want to display background-ground-image on heroku.
02. I made an API to connect to MySQL (MyBatis) from Spring Boot
I want to write a unit test!
Connect from Java to MySQL using Eclipse
Run R from Java I want to run rJava
I want to graduate from npm install properly [2020]
[Ruby] I want to do a method jump!
I want to design a structured exception handling
I want to play with Firestore from Rails
I want to write quickly from java to sqlite
[Java] Connect to MySQL
Connect with VS Code from a Windows client to Docker on another server
[Java] I tried to connect using a connection pool with Servlet (tomcat) & MySQL & Java
[Java] I want to calculate the difference from the date
How to deploy to Heroku from a local docker image
To connect from Spring to MySQL on virtual server (unsolved)
I started MySQL 5.7 with docker-compose and tried to connect
I want to use a little icon in Rails
How to connect to ClearDB from Sequel Pro on Heroku
I want to define a function in Rails Console
I want to add a reference type column later
I want to redirect sound from Ubuntu with xrdp
I want to create a generic annotation for a type
I want to add a delete function to the comment function
I want to convert characters ...
Connect from Java to PostgreSQL
Connect to MySQL 8 with Java
[Android] Connect to MySQL (unfinished)
[Java] I want to convert a byte array to a hexadecimal number
I want to find a relative path in a situation using Path
I want to make a specific model of ActiveRecord ReadOnly
I want to make a list with kotlin and java!
I want to call a method and count the number
I want to make a function with kotlin and java!
I want to create a form to select the [Rails] category
Even in Java, I want to output true with a == 1 && a == 2 && a == 3
I want to give a class name to the select attribute
I want to create a Parquet file even in Ruby
I tried to make a client of RESAS-API in Java
I want to use FireBase to display a timeline like Twitter
I want to return a type different from the input element with Java8 StreamAPI reduce ()
[Java] I definitely want to connect MySQL !!! ~ About getting JDBC driver and JAR file location ~
Swift: I want to chain arrays
I want to recursively search for files under a specific directory
I want to create a chat screen for the Swift chat app!
I want to make a button with a line break with link_to [Note]
I want to connect SONY headphones WH-1000XM4 with LDAC on ubuntu 20.04! !!
[Controller] I want to retrieve the numerical value of a specific column from the DB (my memo)
I want to add a browsing function with ruby on rails
I want to use swipeback on a screen that uses XLPagerTabStrip
I want to INSERT Spring Local Time with MySQL Time (also milliseconds)
[Ruby] I want to put an array in a variable. I want to convert to an array
I want to docker-compose up Next.js!
Upgrade from MYSQL5.7 to 8.0 on CentOS 6.7
How to connect Heroku and Sequel
I am studying to change jobs from inexperienced to a web engineer.
Change DB from SQLite to MySQL
I tried to generate a C language program source from cURL