How to modify master node restart in MySQL?

To modify the MySQL master node and restart it, you can follow these steps:

  1. Log in to the server hosting the MySQL master node.
  2. Open the configuration file for MySQL, usually located at /etc/mysql/my.cnf or /etc/my.cnf path.
  3. Locate the [mysqld] section in the configuration file and add or modify the following parameters:
server-id = <新的主节点ID>
log-bin = mysql-bin
binlog-do-db = <数据库名>

The is a unique number used to identify the main node. is the name of the database to be copied, and this parameter can be repeated if multiple databases need to be copied.

  1. Save and close the configuration file.
  2. Restart the MySQL service by executing the following command in the terminal:
sudo service mysql restart

Alternatively

sudo systemctl restart mysql
  1. Confirm that the MySQL master node has been restarted and the new configuration has taken effect.

Please note that modifying the primary node may cause data inconsistency or interruption in master-slave replication. Make sure to backup important data before making any modifications and proceed with caution during the process.

bannerAds