0

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

  1. http://localhost/phpmyadmin

  2. http://192.168.3.72/phpmyadmin

  3. http://127.0.0.1/phpmyadmin/

All the above Works

But when i try to apply IP4 address to this

var mysql      = require('mysql');
var connection = mysql.createConnection({
  host     : 'localhost',
  user     : 'me',
  password : 'secret'
});

Reference : https://github.com/felixge/node-mysql/#introduction

I get error as :

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

What am i doing wrong?

Ports which are used are:

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     

I tried with 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)

When tried with this post: Remote Connections Mysql Ubuntu

But when tried with : netstat -tulpn | grep :3306

I get output as:

tcp        0      0 192.168.3.72:3306       0.0.0.0:*               LISTEN      -  

Can anybody please assist with this...

Community
  • 1
  • 1
Mithun Shreevatsa
  • 3,588
  • 9
  • 50
  • 95
  • phpMyAdmin is just a MySQL client, it doesn't play any role in getting Node connected to the server. You have to configure MySQL Server to listen on external IP address, which you apparently haven't. – Álvaro González May 21 '15 at 07:45
  • Thanks @Alvaro - When i try from externally telnet: could not resolve 192.168.3.72:3306/telnet: Name or service not known. So may i know how to configure MySQL server plz – Mithun Shreevatsa May 21 '15 at 07:53
  • possible duplicate of [Remote Connections Mysql Ubuntu](http://stackoverflow.com/questions/15663001/remote-connections-mysql-ubuntu) – Álvaro González May 21 '15 at 08:04

3 Answers3

0

Did you try use "127.0.0.1" instead of "localhost"?

PhuLuong
  • 527
  • 4
  • 11
  • `localhost` should resolve to `127.0.0.1`, but this may be worth a try. – Tim Biegeleisen May 21 '15 at 07:40
  • 127.0.0.1 works for mysql connection as it is equivalent to localhost. But i want to share mysql db externally. I want to share it with my IP4 address itself in LAN right? Its not working :( – Mithun Shreevatsa May 21 '15 at 07:42
  • did you try "telnet 192.168.3.72:3306" from other computer in LAN? The problem can be 3306 port denied for remoting – PhuLuong May 21 '15 at 07:47
  • @Tim Biegeleisen - Thanks for your replies. I edited my question with more clear info. Could you please check with the same if that helps in solving my problem – Mithun Shreevatsa May 21 '15 at 09:55
0

You may be trying to connect to MySQL using the wrong port. To find out what port MySQL is listening to you can do this:

Windows (from MySQL):
mysql> SHOW GLOBAL VARIABLES LIKE 'PORT';

Unix:
netstat -tln

Once you have determined the correct port (which is 3306 by default), you can explicitly specify a port when you try to connect from Node:

var connection = mysql.createConnection({
  host     : 'localhost',
  user     : 'me',
  password : 'secret',
  port: 3306
});
Tim Biegeleisen
  • 502,043
  • 27
  • 286
  • 360
0

I finally was able to solve the problem :-)

  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

Finally it gave me result as:

mysql stop/waiting
mysql start/running, process 12210

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

Thanks for all :-)

Mithun Shreevatsa
  • 3,588
  • 9
  • 50
  • 95