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
Share:
25,472

Related videos on Youtube

Andrew
Author by

Andrew

Updated on September 18, 2022

Comments

  • Andrew
    Andrew over 1 year

    I have a 10.237.49.251 IP on eth0 and another IP on another interface

    How do I enable remote mysql calls on eth0 device?

    • Gilles 'SO- stop being evil'
      Gilles 'SO- stop being evil' almost 12 years
      Do 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
    Tadej over 4 years
    Under which section should this be? [client], [mysql] or [mysql]?
  • Alex Leach
    Alex Leach over 4 years
    Don'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 for bind-address in that.
  • Tadej
    Tadej over 4 years
    Found it. It was under [mysqld].