Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is there a secret way to bind MySQL to more than one IP address?

As far as I can see the bind-address parameter in the my.cnf does not support more than one IP and you can't have it more than once.

share|improve this question

migrated from May 6 '10 at 19:25

This question came from our site for professional and enthusiast programmers.

up vote 160 down vote accepted

No, there isn't (I just checked 1 hour ago). You can comment the bind-address in my.cnf:

#bind-address                   =

If you want only 2 IPs, you will then have to use a firewall.

share|improve this answer
Correct. Binding is limited to either 0, 1, or all IP addresses on the server. – Joe Sep 14 '10 at 21:01
Note, however, than you can publish and serve both a local unix socket and a network socket by specifying both the socket and bind-address options. – danorton Mar 30 '12 at 17:04
still true as of today. – Dennis Nolte Aug 11 '14 at 13:07
That is ridiculous. – Phillipp Dec 11 '15 at 15:01
@ChristianLescuyer ah interesting. Thanks :) netstat does show a socket connection on my machine: unix 2 [ ACC ] STREAM LISTENING 175927 31481/mysqld /var/run/mysqld/mysqld.sock I wonder how you'd figure out if specifying -h localhost was using the socket? [not expecting an answer]. – AJP Apr 15 at 11:46

Binding to 127.0.0.x won't make it available to all the devices, it will make it available locally only. If you wish to make it available to all the interfaces, you should use If you wish to access it from more than one, but less than all the interfaces, you should bind to and firewall off the interfaces you don't want to be accessed through.

Also, as a second layer of security, you should make sure that all your MySQL users have host field set to something other than % (ie any host).

share|improve this answer
Unless you have a broken network stack you cannot bind a TCP port to address – John Gardeniers May 6 '10 at 22:49
You can bind to You just can't route to it. If you're on Linux (or even on Windows, just install netcat for windows) try: in one terminal: nc -l 4321 and in a second terminal: telnet <IP of any interface your computer has> 4321 And it will connect to it. – Grey Panther May 18 '10 at 16:49
As I said, unless you have a broken network stack... – John Gardeniers Jun 25 '10 at 2:58
@JohnGardeniers Is that why it's in the linux ip(7) man page defined under special addresses: INADDR_ANY ( means any address for binding;? – ebyrob Jul 24 '13 at 17:06
On Debian, create a file /etc/mysql/conf.d/bindaddress.cnf file with content [mysqld] \n bind-address = – Yves Martin Aug 16 '13 at 12:07

You can't bind to more than one IP address, but you can bind to all available IP addresses instead. If so, just use for a binding address in your MySQL configuration file (e.g. /etc/mysql/my.cnf) as follows:

bind-address    =

If the address is, the server accepts TCP/IP connections on all server host IPv4 interfaces.

Furthermore if the address is ::, the server accepts TCP/IP connections on all server host IPv4 and IPv6 interfaces. Use this address to permit both IPv4 and IPv6 connections on all server interfaces.

Or you can simply comment out bind-address= altogether, so it will bind to all addresses. But make sure that you don't have skip-networking enabled in your my.cnf if you want to allow remote connections as well (Read more: MySQL: Allow both remote AND local connections).

After changing the binding address, don't forget to restart your MySQL server by:

sudo service mysql restart

Eventually you can consider to run multiple instances of MySQL on a single machine (different ports) with Master/Slave replication. Replication enables data from one MySQL database server (the master) to be copied to one or more MySQL database servers (the slaves).

Read more:

share|improve this answer
Actually I was hoping for an option to bind to some, but not all addresses. – BlaM Aug 12 '14 at 17:41

No, you cannot. The page you link to clearly states:

The IP address to bind to. Only one address can be selected. If this option is specified multiple times, the last address given is used.

If no address or is specified, the server listens on all interfaces.

share|improve this answer

I think your question is related to this bug The bug report suggest some workaround.

share|improve this answer
A MySQL feature request dating back from 2005! – Tonin Apr 24 '14 at 14:02

protected by pauska Oct 11 '14 at 14:23

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.