Multi instance installation of MYCAT database cluster series


mycatDatabase multi instance installation of database cluster series

Recently, I have been sorting out the related operations of database cluster. Now I will take some time to sort out the operation summary of MySQL database cluster. It happens that you are looking at this part again for reference. The end of this series includes the following contents: multi database installation, MYCAT deployment and installation, separation of read and write of database, master-slave replication of database, double master and multiple database, and database sub database and table. Each point may correspond to one or more articles. As you have to continue to work, this series of sharing is expected to last about 10 days. If you are interested, you can continue to pay attention to it. I am a rookie, if the writing is not good, hope to give more advice and forgiveness.

OK, don’t force me to go directly to the topic of this time: multi database installation.

1、 Preparatory work:

The main purpose of MYCAT is to realize the database cluster function. Since it is a database cluster, it is necessary to install and deploy multi-point database. Due to the poor conditions, the environment is completely built on your own PC. the most sad thing is that we planned to build a CentOS environment through the virtual machine to deploy, but the computer configuration is a little outdated. The virtual machine starts up and the computer runs very hard. So, it is finally deployed and installed in win10.

This operation is carried out in the window environment. The database installation method adopts the compressed package solution, so the first preparation is to download the MySQL compressed package.

Mysql compression package is the simple download. The first mock exam of Baidu is a fool’s operation. If you look at it, you will understand it.

First, go to the official website of Mysql to download:


Enter the download address of the latest version of MySQL through the above address. Of course, what if you need to download the specified version of MySQL? Don’t get excited. Click archives above to progress to the free version selection download page as follows: select the corresponding version



The specific download method is simpler. Click windows (x86, 64 bit), and zip archiveDownloadYou can enter the browser to download automatically, you just need to wait for the download to finish

2、 Install and deploy the first MySQL

1. First of all: unzip the compressed package downloaded in the first step to the specified folder, and I unzip it to the following folder:


2. Second: create a directory in the root directory after decompression my.ini File, mainly to configure some basic configuration information of MySQL, such as port slogans and so on. This MySQL uses port number: 3308
The specific configuration information is as follows:


port = 3308
#Set 3308 port
port = 3308
#The ID should be kept unique, which will be used later when setting master-slave synchronization
server-id = 3308
#Set MySQL installation directory
basedir=C:\Program Files (x86)\MySQL\MySQL Server 8.0.21_3308
#Set the storage directory of MySQL database data
datadir=C:\Program Files (x86)\MySQL\MySQL Server 8.0.21_3308\data
#Maximum number of connections allowed
#The character set used by the server is the 8-bit Latin1 character set by default
#The default storage engine that will be used when creating a new table
#Setting the default character set of MySQL client


Note: in the above configuration information, no space should be left around each field, otherwise unexpected errors will be waiting for you when initializing mysql.

3. Installation: install mysql, the installation is very simple, a command to complete, follow the following command step by step, will not let you get lost

FirstOpen the command line window: Win + R, and then enter: CMD in the open interface to open the command line form (Note: it is better to open it as an administrator)

SecondExecute the following commands in turn

  # Progress to the previous step, MySQL unzips the bin directory under the folder, and the specific command is as follows

       cd C:\Program Files (x86)\MySQL\MySQL Server 8.0.21_3308\bin

       # Execute the start installation command, in which mysql3308 is the service name, which is MySQL by default. It can be customized. What we do is to install more, so we need to define it and each one should be unique

       mysqld install mysql3308

       # If the execution result shows: Service successfully installed. Congratulations on the successful installation. You can see a service name: mysql3308 in the service list

4. Initialize MySQL database

After the database is installed, is there a question, that is, the account password? Haha, it’s not urgent for initialization to do these things. As for the old rule, just execute the order directly, and continue to execute the following command:

  mysqld –initialize -user=mysql3308 –-console

After the command is executed, you will find that there is a new data file in the MySQL installation folder, and the initialized root password will be displayed on the command line. Please remember this password:


5. Modify registry

Press Win + R, enter regedit in the pop-up box, and click OK to open the registration form;


Find the MySQL path:HKEY_LOCAL_MACHINE–>SYSTEM–>CurrentControlSet–>Services –>mysql3308

Change imagepath to the following:C:\Program Files (x86)\MySQL\MySQL Server 8.0.21_3308\bin\mysqld” mysql3308


6. Start MySQL service

There are two ways to start the service. One is to start the service directly through the command

  net start mysql3308

One is to start the service list manually;

7. Modify MySQL initialization password

When initializing mysql, the default password of the system is not easy to remember, so you need to change it to your own password that is easy to remember. The specific operation is as follows:

Login MySQL command:

MySQL – uroot – P initialization password – p3308 (note that the last P is the port and needs to be capitalized)



Password modification command:set password=password(‘New password ‘);


Through the above step-by-step operation, the basic operation of MySQL is no problem, but there is a small problem, that is, in general, when we connect to the database, we need to support remote connection through IP. By default, the MySQL account does not support remote connection, so it needs to be carried out on the account. The specific operation is as follows:

Use MySQL database: use MySQL;

View the user table: select user, host from user;

Update all users can access: update user set host = ‘%’ where user =’root ‘;

Refresh permissions: flush privileges;


So far, a complete MySQL instance has been installed and started. Do you think it is very simple

3、 Install and deploy the second to n MySQL

There is the first deployment and installation above. No matter how many installations are installed, you can follow the above steps step by step. Only pay attention to the following points: port, server ID, address and service name must be set to the own name of each instance.

The deployment and installation of MySQL will be shared here. The next article will share with you the deployment and installation of MYCAT, database cluster and so on. If you are interested, you can continue to pay attention to it. Thank you!


In order to communicate more, you are welcome to pay attention to my official account.