Connection to Mysql from NodeJS on Heroku server
heroku, mysql, node.js
Solution
Try this. Hope this will help you
mysql://b32fa719432e40:87de815a@us-cdbr-east-04.cleardb.com/heroku_28437b49d76cc53?reconnect=true
var connection = mysql.createConnection({
host : 'us-cdbr-east-04.cleardb.com',
user : 'b32fa719432e40',
password : '87de815a',
database : 'heroku_28437b49d76cc53'
});
Use this details and connect it in mySQL work bench, and import your localhost db
Problem
ANy idea how can I connect from NodeJs to the Mysql ClearDB on Heroku? I was able to connect to the ClearDB Mysql runing on Heroku from Navicat, I even created a table called t_users. But I'm having problems connecting from NodeJs from Heroku. This is my code, it is very simple: everything works find until it tries to connect to MySQL web.js: ``` var express = require("express"); var app = express(); app.use(express.logger()); var mysql = require('mysql'); var connection = mysql.createConnection({ host : 'us-cdbr-east-04.cleardb.com', user : '', password : '', database : '' }); connection.connect(); app.get('/', function(request, response) { response.send('Hello World!!!! HOLA MUNDOOOOO!!!'); connection.query('SELECT 1 + 1 AS solution', function(err, rows, fields) { if (err) throw err; response.send('The solution is: ', rows[0].solution); }); }); var port = process.env.PORT || 5000; app.listen(port, function() { console.log("Listening on " + port); }); ``` This is what I got when I run on the command line: Heroku config ``` C:\wamp\www\Nodejs_MySql_Heroku>heroku config === frozen-wave-8356 Config Vars CLEARDB_DATABASE_URL: mysql://b32fa719432e40:87de815a@us-cdbr-east-04.cleardb.com/heroku_28437b49d76cc53?reconnect=true PATH: bin:node_modules/.bin:/usr/local/bin:/usr/bin:/bin ``` This is the LOG: http://d.pr/i/cExL ANy idea how can I connect from NodeJs to the Mysql ClearDB on Heroku? Thanks