How to allow mysql remote connections via particular interface
25,472
Solution 1
The mysqld configuration file - at /etc/mysql/my.cnf
on my Linux box - has a bind-address
option. This can be set to a particular IP address, like 10.237.49.251, and MySQL will then only listen on that interface (eth0).
The default (at least on Ubuntu) is to listen only on localhost, aka. the loopback interface (127.0.0.1).
Otherwise, MySQL can listen on all available ports and interfaces, which can be explicitly specified with bind-address=0.0.0.0
.
Solution 2
you can use :
iptables -A INPUT -p tcp --dport 3306 -d 10.237.49.251 -i eth0 -j ACCEPT
Related videos on Youtube
Author by
Andrew
Updated on September 18, 2022Comments
-
Andrew over 1 year
I have a
10.237.49.251
IP oneth0
and another IP on another interfaceHow do I enable remote mysql calls on
eth0
device?-
Gilles 'SO- stop being evil' almost 12 yearsDo you mean you want the MySQL server to listen only on a particular interface? Or do you want a MySQL client to choose a particular route to a remote server?
-
-
Tadej over 4 yearsUnder which section should this be? [client], [mysql] or [mysql]?
-
Alex Leach over 4 yearsDon't have a mysql box in front of me, but given your two (three?) options, probably
[mysql]
. A client obviously shouldn't be listening for requests on any IP Address, so shouldn't bind anything. You should have a template my.cnf file anyway, or at least be able to find one online; look forbind-address
in that. -
Tadej over 4 yearsFound it. It was under
[mysqld]
.