Remote connect to clearDB heroku database

MysqlDatabaseHerokuDatabase Connection

Mysql Problem Overview


How can i perform a remote connect to ClearDB MySQL database on heroku using for example MySQL Query Browser. Where to get url, port, login and password?

Mysql Solutions


Solution 1 - Mysql

In heroku website, go to My Apps and select the app on which you have installed ClearDB.

On the top corner click on Addons and then select ClearDB MySQL Database. Once there, click on your database and choose the 'Endpoint Information' tab. There you see your username/password. The URL to the database can be acquired by running heroku config --app <YOUR-APP-NAME> in the command line.

In my case, it was something like: mysql://user:pass@us-cdbr-east.cleardb.com/DATABASE?reconnect=true What you need is this part: us-cdbr-east.cleardb.com

Solution 2 - Mysql

You run heroku config to get the CLEARDB_DATABASE_URL and it should be something of this format:

CLEARDB_DATABASE_URL => mysql://[username]:[password]@[host]/[database name]?reconnect=true

So basically you just look at your own url and get all you want from there. That's how i set up mysql workbench.

Solution 3 - Mysql

Paste this command in terminal

  heroku config | grep CLEARDB_DATABASE_URL

After this you will get Database URL. e.g this is your cleardb database URL.

'mysql://b0600ea495asds:9cd2b111@us-cdbr-hirone-west-
 06.cleardb.net/heroku_4a1dc3673c4114d?reconnect=true'

Than this will be your database credentials. (Extracted from Above URL)

USER NAME = b0600ea495asds

PASSWORD = 9cd2b111

HOST = us-cdbr-hirone-west- 06.cleardb.net

DATABASE NAME = heroku_4a1dc3673c4114d

Solution 4 - Mysql

If you are using mySQL workbench, follow this schema. Go to Heroku > Your Applications Settings > Config Vars, and show the long URL. That url includes your username, password, the URL of the database and the default schema. Paste all of the information as follows below, and you will be able to successfully connect to the database. There was no real explaination on how to connect to ClearDB using mySQL workbench on this thread, so hopefully this helps someone who was struggling.

enter image description here

Solution 5 - Mysql

I did a video explaining how to connect to MySql using NodeJS on a Heroku server, take a look:

http://www.youtube.com/watch?v=2OGHdii_42s

This is the code in case you want to see:

https://github.com/mescalito/MySql-NodeJS-Heroku

Here is part of the code:

var express = require("express");
var mysql      = require('mysql');
var app = express();
app.use(express.logger());

var connection = mysql.createConnection({
  host     : 'us-cdbr-east-04.cleardb.com',
  user     : 'b6d6c6e874',
  password : 'b3f7###',
  database : 'heroku_1daa39da0'
});

connection.connect();

app.get('/', function(request, response) {
  connection.query('SELECT * from t_users', function(err, rows, fields) {
	  if (err) {
	  	console.log('error: ', err);
	  	throw err;
	  }
	  response.send(['Hello World!!!! HOLA MUNDO!!!!', rows]);
	});
});

var port = process.env.PORT || 5000;
app.listen(port, function() {
  console.log("Listening on " + port);
});

CHeers! MAGIC: http://makegif.com/g9yv.gif

Solution 6 - Mysql

Go to your app on heroku and click to the 'settings' tab. Then click the button on the second option that says 'reveal config vars'.

You should find, listed under the CLEARDB_DATABASE_URL variable, something like this...

mysql://[username]:[password]@[host]/[database name]?reconnect=true

So the [host portion] is your host. The [database name] portion is your db name, of course.

You still need your username and password. Go back to the 'overview' tab in heroku. Go to the ClearDB add-on in your installed add-ons section. Click the database you want to access (probably only 1 option there). Click the 'system information' tab. You should see your username and password.

that should be all you need to access your database. I use sequel pro. I just plugged that info (name, host, into the 'standard' tab and I was good to go.

Solution 7 - Mysql

Paste this inside terminal:

heroku config | grep CLEARDB_DATABASE_URL

Solution 8 - Mysql

You can use this one-liner to connect to your MySQL database in your terminal.

$(ruby -e 'require "uri"; uri = URI.parse(ARGV[0]); puts "mysql -u#{uri.user} -p#{uri.password} -h#{uri.host} -D#{uri.path.gsub("/", "")}"' $(ruby -e 'require "uri"; uri = URI.parse(ARGV[0]); puts "mysql -u#{uri.user} -p#{uri.password} -h#{uri.host} -D#{uri.path.gsub("/", "")}"' heroku config:get CLEARDB_DATABASE_URL)
)

Solution 9 - Mysql

For Windows users, there is no grep command.

Just try,

heroku config

There is another way, go to settings in Heroku Web. then config var.

Solution 10 - Mysql

All the details will be in the database URL which can be found in heroku config. Assuming you can connect to ClearDB directly (I've never tried), these should be all you need...

Solution 11 - Mysql

Yes, you can connect to ClearDB directly, actually I use Workbench to connect. Then you can use the same DB for your localhost and for heroku.

Solution 12 - Mysql

All of this worked perfectly for me. Using heroku config | grep, as described above and then simply adding another entry into my config.inc.php for use by phpMyAdmin and I can access my cleardb database remotely. It saves me having to have SQL locally and using postgres with Heroku.

Solution 13 - Mysql

should consider getting the credentials of vars in heroku configurations (Config Vars):

CLEARDB_DATABASE_URL

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionromanView Question on Stackoverflow
Solution 1 - MysqlAbbasView Answer on Stackoverflow
Solution 2 - MysqlAndreiView Answer on Stackoverflow
Solution 3 - MysqlDevelopineView Answer on Stackoverflow
Solution 4 - MysqlJordan SchuetzView Answer on Stackoverflow
Solution 5 - MysqllitoView Answer on Stackoverflow
Solution 6 - Mysqluser2364424View Answer on Stackoverflow
Solution 7 - Mysqluser3805474View Answer on Stackoverflow
Solution 8 - MysqlSébastien SaunierView Answer on Stackoverflow
Solution 9 - MysqlMuhammad Imran SiddiqueView Answer on Stackoverflow
Solution 10 - MysqlNeil MiddletonView Answer on Stackoverflow
Solution 11 - MysqlAlisson Reinaldo SilvaView Answer on Stackoverflow
Solution 12 - MysqlGiantCoderView Answer on Stackoverflow
Solution 13 - MysqlDiego Santa Cruz MendezúView Answer on Stackoverflow