简体   繁体   中英

How can I connect Heroku ClearDB to MySQL Workbench?

The clearDB 'How to Connect' page just says "You can connect with MySQL Workbench".

When I open MySQL Workbench and connect I need the following:

  • Connection Method
  • Port
  • Host Name
  • Username
  • Password

I assume my username and password is the Heroku one, but what about the host name? Where do I find this?

I assume my username and password is the Heroku one

Certainly not.

You should never reuse credentials across services, and ClearDB won't make that mistake. Like most database services on Heroku, ClearDB provides an environment variable containing connection information :

Retrieve your database URL by issuing the following command:

 $ heroku config | grep CLEARDB_DATABASE_URL CLEARDB_DATABASE_URL => mysql://adffdadf2341:adf4234@us-cdbr-east.cleardb.com/heroku_db?reconnect=true

The value given here is a standard URI , and you can pull individual values out based on that standard. In this example:

  • User: adffdadf2341
  • Password: adf4234
  • Host: us-cdbr-east.cleardb.com
  • Database: heroku_db

There is no port in this example, so you'd use the default MySQL port of 3306 (MySQL Workbench should know this and use it by default). If a port were provided, it would appear after the host, eg 11111 here:

us-cdbr-east.cleardb.com:11111/heroku_db

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM