Ip4address 不适用于 node-mysql 连接 ubuntu [英] Ip4address not working for node-mysql connection ubuntu

查看:66
本文介绍了Ip4address 不适用于 node-mysql 连接 ubuntu的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以使用本地主机和我的 IP4 地址打开 phpmyadmin:

I am able to open phpmyadmin with both localhost as well as my IP4 address:

  1. http://localhost/phpmyadmin

http://192.168.3.72/phpmyadmin

以上所有作品

但是当我尝试将 IP4 地址应用于此

But when i try to apply IP4 address to this

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

但我得到空白输出而不是:

But i get blank output instead of :

mysqld  1046  mysql  10u  IPv4  5203  0t0  TCP  xxx.xxx.xxx.xxx:3306 (LISTEN)

尝试使用这篇文章时:远程连接 Mysql Ubuntu

但是当尝试使用:netstat -tulpn |grep :3306

我得到的输出为:

tcp        0      0 192.168.3.72:3306       0.0.0.0:*               LISTEN      -  

有人可以帮忙吗...

推荐答案

我终于能够解决问题了 :-)

I finally was able to solve the problem :-)

  1. 我使用 sudo su
  2. 以 root 身份登录
  3. 编辑subl/etc/mysql/my.cnf &用我的 IP4 地址替换 bind-address
  4. 运行:service mysql restart
  1. I logged in as root using sudo su
  2. Edited subl /etc/mysql/my.cnf & Replace bind-address with my IP4 address
  3. Run : service mysql restart

最后它给了我结果:

mysql stop/waiting
mysql start/running, process 12210

现在我可以使用外部来源的 IP4 地址成功登录了.

And now i am able to login successfully using IP4 address from external sources.

谢谢大家:-)

这篇关于Ip4address 不适用于 node-mysql 连接 ubuntu的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆