node.js - Connection to Mysql from NodeJS on Heroku server -


any idea how can connect nodejs mysql cleardb on heroku?

i able connect cleardb mysql runing on heroku navicat, created table called t_users. i'm having problems connecting nodejs heroku.

this code, simple: works find until tries connect 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 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 got when run on 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 log: http://d.pr/i/cexl

any idea how can connect nodejs mysql cleardb on heroku? thanks

try this. hope 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 details , connect in mysql work bench, , import localhost db


Comments

Popular posts from this blog

java - Run a .jar on Heroku -

java - Jtable duplicate Rows -

validation - How to pass paramaters like unix into windows batch file -