1

To allow connections from outside, I edited /etc/mysql/my.cnf to change the bind-address from the default value 127.0.0.1 to 54.200.xx.xx. But after changing making the change, mysql service won't start. When I checked the mysql error log, it has this:-

131030 12:27:53 [Note] Server hostname (bind-address): '54.200.xx.xx'; port: 3306
131030 12:27:53 [Note]   - '54.200.xx.xx' resolves to '54.200.xx.xx';
131030 12:27:53 [Note] Server socket created on IP: '54.200.xx.xx'.
131030 12:27:53 [ERROR] Can't start server: Bind on TCP/IP port: Cannot assign requested address
131030 12:27:53 [ERROR] Do you already have another mysqld server running on port: 3306 ?
131030 12:27:53 [ERROR] Aborting

The server is on Amazon EC2, running Ubuntu 12.04 LTS. Any idea what the problem is?

ubuntu@ip-172-31-xx-xxx:~$ ifconfig
eth0      Link encap:Ethernet  HWaddr 12:ad:52:a1:9b:a9  
          inet addr:172.31.xx.xxx  Bcast:172.31.xx.xxx  Mask:255.255.240.0
          inet6 addr: fe80::10ad:52ff:fea1:9ba9/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:1014 errors:0 dropped:0 overruns:0 frame:0
          TX packets:749 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:87102 (87.1 KB)  TX bytes:138261 (138.2 KB)
          Interrupt:25 

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:152 errors:0 dropped:0 overruns:0 frame:0
          TX packets:152 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:11740 (11.7 KB)  TX bytes:11740 (11.7 KB)
6
  • Does the IP exists on the server? ifconfig/netstat output... FYI some applications try to use localhost/127.0.0.1 why communicating with the database... You probably better to let it listen on all IPs.
    – jirib
    Oct 30, 2013 at 12:55
  • ifconfig output - paste.ubuntu.com/6329855 netstat output - paste.ubuntu.com/6329861
    – Sparky
    Oct 30, 2013 at 12:58
  • I can add more than one bind-address, while keeping 127.0.0.1?
    – Sparky
    Oct 30, 2013 at 12:58
  • Please do not link output to some 3rd party web sites. There's not reason for that and some people hate it.
    – jirib
    Oct 30, 2013 at 13:04
  • Please give us the output of netstat -lnp | grep 3306
    – mveroone
    Oct 30, 2013 at 13:09

2 Answers 2

12

You cannot listen on an IP if this IP is not on your system. This is clear, isn't it?

1
  • That was so obvious... my bad.
    – mveroone
    Oct 30, 2013 at 13:10
4

** sorry - just saw that you said you're on EC2 - you'll still need to bind your MySQL instance to 0.0.0.0 and then do any appropriate configuration if necessary to get port 3306 opened if the default is not to just send all traffic through to your LAN IP **

Looks like you're on a LAN with a NAT gateway in front of it. You can't bind mysql to your external IP address directly, as that's not actually an IP address that's available on your system.

If this is really what you want to do (consider the usual security implications of just opening up direct access to the outside world), you will need to:

  • Bind MySQL to 0.0.0.0 (or your LAN IP, if you don't want it to listen on 127.0.0.1 as well, which is unlikely)
  • Create a port forward/firewall rule from the device that has your external IP on it, for TCP port 3306, to the LAN IP of your linux box.

If you don't know how to do this, there's plenty of information online on setting up port forwards. If you don't have access to the NAT router/firewall and the people who control it won't do it for you, you're going to have to come up with another way to service your needs.

1
  • You're welcome! Please accept an answer to mark this as solved :)
    – Phil
    Oct 30, 2013 at 13:30

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .