SQL Keywords

SQL MASTER_BIND

What is MASTER_BIND in MySQL replication?

MASTER_BIND binds the replica’s outgoing replication connection to a specific local IP address or network interface when issuing CHANGE MASTER TO or START SLAVE in MySQL.
Sign up to get up to date news on SQL keywords
Welcome to the Galaxy, Guardian!
You'll be receiving a confirmation email

Follow us on twitter :)
Oops! Something went wrong while submitting the form.

Compatible dialects for SQL MASTER_BIND: MySQL 5.6+, MySQL 8.x, MariaDB 10.x (as CHANGE MASTER TO MASTER_BIND)

SQL MASTER_BIND Full Explanation

MASTER_BIND is an optional clause used inside the MySQL replication statements CHANGE MASTER TO and START SLAVE (or START REPLICA in newer versions). When supplied, the replica (formerly called the slave) binds its network socket to the given local IPv4 or IPv6 address before initiating the TCP connection to the primary (master) server. This is useful on multi-homed hosts that have multiple NICs or IPs and you need to enforce a particular source address for replication traffic, meet firewall rules, or keep replication traffic on a dedicated VLAN.Behavior:- Operates only on the replica side.- Accepts a literal IP address. Host names and interface names are not supported.- If the supplied address is not present on any local interface, the bind fails and replication does not start.- Applies immediately after CHANGE MASTER TO if SQL_THREAD or IO_THREAD is started. Otherwise it takes effect when START SLAVE is executed.- Works for both IPv4 and IPv6 as long as the operating system allows binding to that address.Caveats:- Does not retroactively affect an already open replication connection; you must restart replication threads.- Only one address can be supplied.- Not supported on Windows prior to MySQL 8.0.13.- Ignored on Group Replication channels; only traditional asynchronous or semi-sync channels honor it.

SQL MASTER_BIND Syntax

CHANGE MASTER TO
  MASTER_HOST = '<master_host>',
  MASTER_USER = '<repl_user>',
  MASTER_PASSWORD = '<repl_pwd>',
  MASTER_BIND = '<local_ip>';

SQL MASTER_BIND Parameters

  • ip_address (string) - Required literal IPv4 or IPv6 address on the replica host that the replication socket should bind to.

Example Queries Using SQL MASTER_BIND

-- Configure replica to use a dedicated replication NIC
CHANGE MASTER TO
  MASTER_HOST = 'primary-db',
  MASTER_USER = 'repl',
  MASTER_PASSWORD = 'repl_pwd',
  MASTER_PORT = 3306,
  MASTER_BIND = '192.168.50.10';

-- Start replication so the bind takes effect
START SLAVE;

Expected Output Using SQL MASTER_BIND

#VALUE!

Use Cases with SQL MASTER_BIND

  • Enforcing replication traffic over a private subnet or VPN interface
  • Meeting firewall or routing policies that whitelist specific source IPs
  • Isolating replication traffic from application traffic on multi-homed servers
  • Debugging network issues by pinning replication to a known interface

Common Mistakes with SQL MASTER_BIND

  • Supplying a host name instead of a literal IP address
  • Forgetting to run START SLAVE after setting MASTER_BIND, leaving old connection intact
  • Using an IP not configured on the server and wondering why replication will not start
  • Expecting MASTER_BIND to work for Group Replication or channel connections it does not control

Related Topics

CHANGE MASTER TO, START SLAVE, MASTER_HOST, MASTER_PORT, replication channels, source-address binding

First Introduced In

MySQL 5.6

Frequently Asked Questions

What is the purpose of MASTER_BIND?

MASTER_BIND tells the replica which local IP address to use when opening the replication socket. This lets you force replication traffic through a specific network interface.

Is MASTER_BIND mandatory for setting up replication?

No. Replication works fine without it. Use it only when you need strict control over the replica’s source IP address.

How do I verify that MASTER_BIND is active?

Run SHOW SLAVE STATUS and inspect the value of Master_Host and the operating system’s netstat or ss output. The local address column should show the IP given in MASTER_BIND.

Can I supply multiple addresses?

No. The option accepts exactly one address. If you need failover across interfaces you must script a CHANGE MASTER TO with a different MASTER_BIND or use OS-level IP takeover tools.

Sign up to get up to date news on SQL keywords
Welcome to the Galaxy, Guardian!
You'll be receiving a confirmation email

Follow us on twitter :)
Oops! Something went wrong while submitting the form.
Trusted by top engineers on high-velocity teams
Aryeo Logo
Assort Health
Curri
Rubie Logo
Bauhealth Logo
Truvideo Logo

Check out other commonly used SQL Keywords!