【发布时间】:2015-05-21 23:51:25
【问题描述】:
我可以使用 localhost 和我的 IP4 地址打开 phpmyadmin:
以上所有作品
但是当我尝试将 IP4 地址应用到这个时
var mysql = require('mysql');
var connection = mysql.createConnection({
host : 'localhost',
user : 'me',
password : 'secret'
});
参考:https://github.com/felixge/node-mysql/#introduction
我得到错误:
{ [Error: connect ECONNREFUSED]
code: 'ECONNREFUSED',
errno: 'ECONNREFUSED',
syscall: 'connect',
fatal: true }
我做错了什么?
使用的端口有:
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 127.0.1.1:53 0.0.0.0:* LISTEN
tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN
tcp 0 0 127.0.0.1:27017 0.0.0.0:* LISTEN
tcp 0 0 127.0.0.1:3306 0.0.0.0:* LISTEN
tcp 0 0 127.0.0.1:28017 0.0.0.0:* LISTEN
tcp 0 0 127.0.0.1:5939 0.0.0.0:* LISTEN
tcp6 0 0 ::1:631 :::* LISTEN
tcp6 0 0 :::80 :::* LISTEN
我试过netstat -nlt | grep 3306
但我得到的是空白输出而不是:
mysqld 1046 mysql 10u IPv4 5203 0t0 TCP xxx.xxx.xxx.xxx:3306 (LISTEN)
尝试使用此帖子时: Remote Connections Mysql Ubuntu
但是当尝试使用:netstat -tulpn | grep :3306
我得到的输出为:
tcp 0 0 192.168.3.72:3306 0.0.0.0:* LISTEN -
有人可以帮忙吗...
【问题讨论】:
-
phpMyAdmin 只是一个 MySQL 客户端,它在让 Node 连接到服务器方面没有任何作用。您必须配置 MySQL 服务器以侦听外部 IP 地址,而您显然没有。
-
感谢@Alvaro - 当我从外部 telnet 尝试时:无法解析 192.168.3.72:3306/telnet:名称或服务未知。所以我可以知道如何配置 MySQL 服务器 plz
标签: mysql node.js node-mysql