Databases 3 min read

Quickly Set Up MySQL Master‑Slave Replication with mysqlreplicate

This guide introduces MySQL Utilities, demonstrates how to configure master‑slave replication in seconds using the mysqlreplicate command, explains required user creation, showcases additional tools like mysqldiskusage and mysqlindexcheck, and provides installation and download instructions.

Java High-Performance Architecture
Java High-Performance Architecture
Java High-Performance Architecture
Quickly Set Up MySQL Master‑Slave Replication with mysqlreplicate

MySQL Utilities is a toolbox of handy MySQL tools. One of the most useful commands is mysqlreplicate, which can configure a master‑slave replication environment with a single command.

Usage

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

--master specifies the master server connection, --slave specifies the slave server, and --rpl-user provides the replication user that must already exist on the master.

First, create the replication user on the master, for example:

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

Note: the slave IP must be explicit; do not use ‘%’.

Only two steps are needed: (1) create the replication user on the master, and (2) run the mysqlreplicate command. The setup completes in a few seconds.

MySQL Utilities includes many other tools, such as mysqldiskusage to view database space usage:

mysqldiskusage --server=root:111111@localhost
mysqldiskusage output
mysqldiskusage output

Another useful command is mysqlindexcheck to detect redundant indexes:

mysqlindexcheck --server=root@localhost employees
mysqlindexcheck result
mysqlindexcheck result

Installation

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 and Documentation

Download: 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.

mysqlReplicationInstallationDatabase Toolsmysqlreplicate
Java High-Performance Architecture
Written by

Java High-Performance Architecture

Sharing Java development articles and resources, including SSM architecture and the Spring ecosystem (Spring Boot, Spring Cloud, MyBatis, Dubbo, Docker), Zookeeper, Redis, architecture design, microservices, message queues, Git, etc.

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.