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.
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:111111Parameters:
-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 installAfter 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
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
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!
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
