Statement
The Stars last night
Blog:http://yestreenstars.blog.51cto.com/
This article by oneself creation, if need reprint, please indicate source, thank cooperation!
Objective
MySQL multi-port multiple instance running under Linux.
Main operation
Create a/ETC/MY_MULTI.CNF file
Vi/etc/my_multi.cnf
The content is as follows ( Note!) If your MySQL is installed by source code, change the mysqld and mysqladmin as appropriate, and pay attention to changing the root password. )
[MYSQLD_MULTI]MYSQLD =/usr/bin/mysqld_safemysqladmin =/usr/bin/mysqladminlog =/var/log/mysqld_multi.loguser = Rootpassword = Redhat[mysqld1]user = Mysqlport = 3307datadir =/data1pid-file =/data1/mysqld.pidsocket =/data1/mysql.soc K[mysqld2]user = Mysqlport = 3308datadir =/data2pid-file =/data2/mysqld.pidsocket =/data2/mysql.sock
Create Data Catalog ( Note!) Please create it based on what you actually configured in the/etc/my_multi.cnf file. )
Mkdir/data1chown mysql:mysql/data1mysql_install_db--datadir=/data1mkdir/data2chown Mysql:mysql/data2mysql_ install_db--datadir=/data2
Attention! You can also copy the data directory of the existing database directly, but pay attention to the configuration of the permissions.
Start all DB instances
Mysqld_multi--defaults-extra-file=/etc/my_multi.cnf Start
Configure the same root password for each database (as in/etc/my_multi.cnf)
Mysqladmin-s/data1/mysql.sock-uroot password redhatmysqladmin-s/data1/mysq2.sock-uroot password Redhat
This is the end of the entire configuration.
Related content
# log path/var/log/mysqld_multi.log# start all DB instances Mysqld_multi--defaults-extra-file=/etc/my_multi.cnf start# Stop all DB instances Mysqld_multi--defaults-extra-file=/etc/my_multi.cnf stop# start only one DB instance Mysqld_multi--defaults-extra-file=/ ETC/MY_MULTI.CNF Start # Only stops a DB instance Mysqld_multi--defaults-extra-file=/etc/my_multi.cnf Stop # to connect to the database based on the port Mysql-s/ Data1/mysql.sock-uroot-p
This article is from the "Last Night Stars" blog, please make sure to keep this source http://yestreenstars.blog.51cto.com/1836303/1619294
MySQL multiport multi-instance operation implemented under Linux