How to Check Replication Status in MySQL Quickly
To check replication status in MySQL, use the
SHOW SLAVE STATUS\G command on the replica server. This command shows detailed information about the replication process, including whether it is running correctly and any errors.Syntax
The main command to check replication status on a MySQL replica is SHOW SLAVE STATUS\G. It returns a detailed report about the replication threads and their current state.
SHOW SLAVE STATUS\G: Displays replication status in a vertical format for readability.Slave_IO_Running: Shows if the IO thread is running (Yes/No).Slave_SQL_Running: Shows if the SQL thread is running (Yes/No).Last_Error: Displays the last error message if replication failed.
mysql
SHOW SLAVE STATUS\G
Example
This example shows how to run the command on a replica server and interpret key fields to confirm replication is working.
mysql
mysql> SHOW SLAVE STATUS\G *************************** 1. row *************************** Slave_IO_State: Waiting for master to send event Master_Host: 192.168.1.100 Master_User: repl_user Slave_IO_Running: Yes Slave_SQL_Running: Yes Last_Error: Seconds_Behind_Master: 0
Output
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
Last_Error: (empty)
Seconds_Behind_Master: 0
Common Pitfalls
Common mistakes when checking replication status include:
- Running
SHOW SLAVE STATUSon the master server instead of the replica. - Ignoring the
Slave_IO_RunningorSlave_SQL_Runningfields which indicate if replication threads are active. - Not checking
Last_Errorfor replication problems. - Confusing
Seconds_Behind_Masterwhich shows replication lag but can be NULL if replication is broken.
mysql
/* Wrong: Running on master server */ mysql> SHOW SLAVE STATUS\G /* Output is empty because master has no slave status */ /* Right: Run on replica server */ mysql> SHOW SLAVE STATUS\G Slave_IO_Running: Yes Slave_SQL_Running: Yes Last_Error: (empty)
Quick Reference
| Field | Meaning |
|---|---|
| Slave_IO_Running | Shows if the IO thread is running (Yes/No) |
| Slave_SQL_Running | Shows if the SQL thread is running (Yes/No) |
| Last_Error | Last replication error message, empty if none |
| Seconds_Behind_Master | Replication lag in seconds, 0 means up to date |
| Master_Host | IP or hostname of the master server |
Key Takeaways
Use SHOW SLAVE STATUS\G on the replica to check replication status.
Check Slave_IO_Running and Slave_SQL_Running fields to confirm replication threads are active.
Look at Last_Error to detect any replication problems.
Seconds_Behind_Master shows how delayed the replica is compared to the master.
Do not run SHOW SLAVE STATUS on the master server; it returns no data there.