2014-03-07 108 views
0

我正在使用代理服務器,我試圖訪問以下public數據庫。node.js +公共mysql數據庫:「連接ECONNREFUSED」

連接正常使用mysql客戶端,從我的工作地點:

$ mysql -A -u genome -h genome-mysql.cse.ucsc.edu -P 3306 -D hg19 -e 'select now()' 
+---------------------+ 
| now()    | 
+---------------------+ 
| 2014-03-06 01:56:36 | 
+---------------------+ 

現在,我試圖做使用節點同樣的事情:

var mysql = require('mysql'); 
var connection = mysql.createConnection({ 
    debug:true, 
    trace:true, 
    host : 'genome-mysql.cse.ucsc.edu', 
    port : 3306, 
    database: 'hg19', 
    user : 'genome', 
    password: '' 
}); 
connection.connect(function(err) {if(err!=null) console.log(err);}); 
connection.end(); 

它從我的工作但它會引起我的工作場所的錯誤

{ [Error: connect ECONNREFUSED] 
    code: 'ECONNREFUSED', 
    errno: 'ECONNREFUSED', 
    syscall: 'connect', 
    fatal: true } 

sam e錯誤使用:_socket: '/var/run/mysqld/mysqld.sock' as connect ECONNREFUSED - node js , sql

有關如何解決此問題的任何建議?

+0

的可能重複一個probem [連接ECONNREFUSED - 節點JS,SQL](http://stackoverflow.com/questions/8825342/connect- econnrefused-node-js-sql) –

+0

不是重複的:它不是我的mysql服務器我不能設置'跳過網絡',我嘗試了你建議的解決方案。 – Pierre

回答

1

固定。這是我的版本node.js的問題:

固定。這是我在Ubuntu

[email protected]:~/tmp/NODE$ /usr/bin/node -v && /usr/bin/node test2.js 
v0.6.12 
{ [Error: connect ECONNREFUSED] 
    code: 'ECONNREFUSED', 
    errno: 'ECONNREFUSED', 
    syscall: 'connect', 
    fatal: true } 

節點VS

$ ~/package/node/bin/node -v && ~/package/node/bin/node test2.js 
v0.10.26 
<-- HandshakeInitializationPacket 
{ protocolVersion: 10, 
    serverVersion: '5.6.10-log', 
    threadId: 9810250, 
    scrambleBuff1: <Buffer 46 33 6a 3f 39 41 79 61>, 
    filler1: <Buffer 00>, 
    serverCapabilities1: 63487, 
    serverLanguage: 8, 
    serverStatus: 2, 
    serverCapabilities2: 32895, 
    scrambleLength: 21, 
    filler2: <Buffer 00 00 00 00 00 00 00 00 00 00>, 
    scrambleBuff2: <Buffer 5a 7c 26 43 5c 28 50 3c 79 6d 39 71>, 
    filler3: <Buffer 00>, 
    pluginData: 'mysql_native_password', 
    protocol41: true } 
+0

由於ubuntu存儲庫上的舊Node.js版本,這似乎是一個常見問題。也許,我們可以在README上爲node-mysql或其他集中位置添加註釋。 – bitsoflogic