Databases 4 min read

Quickly Set Up MySQL Master‑Slave Replication with mysqlreplicate

This guide explains how MySQL's asynchronous replication works, shows how to configure a master‑slave setup in seconds using the mysqlreplicate command from MySQL Utilities, and introduces additional utility commands for disk usage and index checking.

Java Backend Technology
Java Backend Technology
Java Backend Technology
Quickly Set Up MySQL Master‑Slave Replication with mysqlreplicate

MySQL replication (asynchronous) is a widely used master‑slave synchronization solution for higher performance and reliability.

Unlike the more complex MySQL Cluster, replication can be set up quickly with MySQL Utilities.

The mysqlreplicate command configures the environment in one step:

mysqlreplicate \
-master=root:[email protected]:3306 \
-slave=root:[email protected]:3306 \
-rpl-user=replutil:111111

Parameters:

-master : connection info of the master server

-slave : connection info of the slave server

-rpl-user : replication user (must be created on the master beforehand)

Create the replication user on the master, for example:

grant ALL PRIVILEGES on *.* to replutil@"192.168.31.101" identified by "111111";

Note: specify the slave IP explicitly; do not use ‘%’.

Only two steps are required: (1) create the replication user on the master, (2) run the mysqlreplicate command. The master‑slave configuration completes in seconds.

MySQL Utilities also provide other useful commands, such as: mysqldiskusage --server=root:111111@localhost – shows database space usage. mysqlindexcheck --server=root@localhost employees – checks for redundant indexes in the employees database.

Installing MySQL Utilities

Download and extract MySQL Utilities, then run:

python ./setup.py build
python ./setup.py install

After installation, the utility commands are ready to use.

Download URL: http://dev.mysql.com/downloads/utilities/1.5.html

Documentation: http://dev.mysql.com/doc/mysql-utilities/1.6/en/utils-overview.html

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

mysqlReplicationmysqlreplicateMySQL Utilities
Java Backend Technology
Written by

Java Backend Technology

Focus on Java-related technologies: SSM, Spring ecosystem, microservices, MySQL, MyCat, clustering, distributed systems, middleware, Linux, networking, multithreading. Occasionally cover DevOps tools like Jenkins, Nexus, Docker, and ELK. Also share technical insights from time to time, committed to Java full-stack development!

0 followers
Reader feedback

How this landed with the community

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.