Databases 6 min read

Master MySQL Replication: Fix Common Errors and Resolve ‘command not found’ Issues

Learn step‑by‑step how to troubleshoot MySQL master‑slave replication problems, from verifying component roles and executing the correct SHOW SLAVE STATUS command inside the MySQL client, to fixing missing command errors, checking IO/SQL threads, and restarting replication in Docker‑based environments.

IT Xianyu
IT Xianyu
IT Xianyu
Master MySQL Replication: Fix Common Errors and Resolve ‘command not found’ Issues

DBAs often encounter situations where data written to the master does not replicate to the slaves, or replication lag is severe, and the command

show slave status

appears as "bash: show slave status: command not found". This guide walks through diagnosing and fixing those issues.

1. Environment recap

Three servers: master, node1, node2.

All run AlmaLinux and host Docker containers with one MySQL master and two MySQL slaves.

Data is written on the master and should be synchronized to node1 and node2.

2. Master‑slave replication components

Master : writes data changes to the binary log (binlog).

Slave (node1 / node2) : reads the binlog from the master and executes the changes.

IO thread : on the slave, connects to the master and pulls the binlog.

SQL thread : on the slave, reads the binlog and runs the SQL statements.

3. Where to run the commands

On the master : use the MySQL client to check master status and enable binlog.

On the slave : use the MySQL client to check replication status and start/stop replication threads.

4. Viewing replication status

Execute the following inside the MySQL client on a slave:

<code>SHOW SLAVE STATUS\G</code>

This command is an internal MySQL SQL statement, not a Linux shell command.

5. Correct way to enter the MySQL client

SSH into the target slave server (node1 or node2):

<code>ssh user@node1</code>

Enter the Docker container (assuming the container is named

mysql_slave1

):

<code>docker exec -it mysql_slave1 bash</code>

Launch the MySQL client:

<code>mysql -uroot -p</code>

Enter the password when prompted.

Run the replication‑status command:

<code>SHOW SLAVE STATUS\G</code>

No "bash: show: command not found" error will appear.

6. Common replication errors and troubleshooting

Slave_IO_Running: No – the IO thread is not running, so the slave cannot pull the master’s binlog.

Slave_SQL_Running: No – the SQL thread is not running; the binlog is fetched but not executed.

Last_IO_Error / Last_SQL_Error – display the specific error messages.

Typical troubleshooting steps:

Verify network connectivity and that port 3306 is open on both sides.

Check that the replication user has the proper privileges.

Inspect the MySQL error log (usually

/var/log/mysql/error.log

inside the container).

7. Fixing "bash: mysql: command not found"

The error occurs because the MySQL client is not installed or not in the PATH.

Confirm installation:

<code>which mysql</code>

No output means it is missing.

Install the client on AlmaLinux:

<code>sudo yum install mysql</code>

If the host lacks the client but the database runs in Docker, execute the client directly inside the container:

<code>docker exec -it mysql_slave1 mysql -uroot -p</code>

8. Restarting replication

If replication has stopped, run the following inside the MySQL client on the slave:

<code>STOP SLAVE;
START SLAVE;
SHOW SLAVE STATUS\G</code>

9. Sample output of SHOW SLAVE STATUS

SHOW SLAVE STATUS screenshot
SHOW SLAVE STATUS screenshot
DockerdatabaseLinuxMySQLReplicationTroubleshooting
IT Xianyu
Written by

IT Xianyu

We share common IT technologies (Java, Web, SQL, etc.) and practical applications of emerging software development techniques. New articles are posted daily. Follow IT Xianyu to stay ahead in tech. The IT Xianyu series is being regularly updated.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.