Get the App
SLTechnology News&Howtos  ›  Database  › 

Example Analysis of Mysqld_multi in MySQL

Shulou Source: shulou.com Published: 2022-05-31 15:57:42 10月04日 Update

This article will explain in detail the example analysis of Mysqld_multi in MySQL. The editor thinks it is very practical, so I share it with you for reference. I hope you can get something after reading this article.

Mysqld_multi multiple instances

Mysql multi-instance refers to running multiple mysqld processes on one server at the same time. This article shows the deployment process of multi-instance, which is managed simply through a single configuration file and mysqld_multi command.

1) prepare the parameter file / etc/my.cnf or / etc/mysqld_multi.cnf

[root@db1 ~] # cat / etc/mysqld_multi.cnf

[mysqld_multi]

Mysqld = / usr/bin/mysqld_safe

Mysqladmin = / usr/bin/mysqladmin

User = multi_admin

Password = multipass

[mysqld1]

Port=3306

Basedir=/usr

Datadir=/data/mysql/data

Socket=/data/mysql/mysql.sock

Pid-file=/var/run/mysqld/mysqld.pid

Log-error=/data/mysql/log/mysqld.log

User=mysql

[mysqld2]

Port=3307

Basedir=/usr

Datadir=/data/mysql/data2

Socket=/data/mysql/mysql2.sock

Pid-file=/var/run/mysqld/mysqld2.pid

Log-error=/data/mysql/log/mysqld2.log

User=mysql

2) initialize the database

Method 1:

Mysql_install_db-datadir=/data/mysql/data-user=mysql

Mysql_install_db-datadir=/data/mysql/data2-user=mysql

The temporary password for mysql_install_db initialization data is ~ / .mysql_secret

Method 2:

/ usr/sbin/mysqld-initialize-datadir=/data/mysql/data2-user=mysql

Temporary passwords are recorded in log-error (usually / var/log/mysqld.log)

/ usr/sbin/mysqld-defaults-file=/etc/my.cnf-initialize-datadir=/data/mysql/data2-user=mysql

Method 3:

Mysqld_multi start 2

(it is actually mysql_install_db that initializes the database)

3) create a multi_admin administrative user

Mysql > create user multi_admin@localhost identified by 'multipass'

Mysql > grant shutdown on *. * to multi_admin@localhost identified by 'aa12AA,.'

4) start and stop multiple instances

Mysqld_multi start 1

Mysqld_multi start 2

Mysqld_multi start 1,2

Mysqld_multi start 1-2

Mysqld_multi stop 1

Mysqld_multi stop 2

Mysqld_multi stop 1,2

Mysqld_multi stop 1-2

Mysqladmin-S / data/mysql/mysql2.sock-umulti_admin-p shutdown

This is the end of this article on "sample Analysis of Mysqld_multi in MySQL". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, please share it for more people to see.

Tags: Instances data methods articles examples analysis passwords databases files more management good practical content parameters at the same time commands multiple actual actually Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Microsoft Apple OPPO Reno Redmi Shulou Information