Frequent system hardware shortages, resulting in the need to install multiple MySQL instances on the same hardware server
1. Create a new mysql3306,mysql3307,mysql3308 three folder under the MySQL user directory, and create the Data,log,tmp folder under the three folders respectively, the overall directory structure is as follows
/home/mysql
├──mysql3306
├──data
├──log
├──tmp
├──mysql3307
├──data
├──log
├──tmp
├──mysql3308
├──data
├──log
├──tmp
2. Configuring the My.cnf File
[Client]port=3306Socket=/tmp/Mysql.sock [Mysqld_multi]mysqld=/usr/local/mysql/bin/Mysqld_safemysqladmin=/usr/local/mysql/bin/Mysqladminlog=/home/mysql/Mysqld_multi.log[mysqld]user=Mysqlbasedir=/usr/local/Mysqlsql_mode=no_engine_substitution,strict_trans_tables[mysqld3306] Mysqld=mysqld mysqladmin=mysqladmin DataDir=/home/mysql/mysql3306/Data Port=3306server_id=3306Socket=/tmp/Mysql3306.sock Log-output=file Slow_query_log=1Long_query_time=1Slow_query_log_file=/home/mysql/mysql3306/log/Slow.log Log-error =/home/mysql/mysql3306/log/Error.log Binlog_format=Mixed Log-bin =/home/mysql/mysql3306/log/Mysql3306_bin[mysqld3307]mysqld=Mysqldmysqladmin=Mysqladmindatadir=/home/mysql/mysql3307/dataport=3307server_id=3307Socket=/tmp/Mysql3307.socklog-output=Fileslow_query_log=1Long_query_time=1Slow_query_log_file=/home/mysql/mysql3307/log/Slow.loglog-error =/home/mysql/mysql3307/log/Error.logbinlog_format=Mixedlog-bin =/home/mysql/mysql3307/log/Mysql3307_bin[mysqld3308]mysqld=Mysqldmysqladmin=Mysqladmindatadir=/home/mysql/mysql3308/dataport=3308server_id=3308Socket=/tmp/Mysql3308.socklog-output=Fileslow_query_log=1Long_query_time=1Slow_query_log_file=/home/mysql/mysql3308/log/Slow.loglog-error =/home/mysql/mysql3308/log/Error.logbinlog_format=Mixedlog-bin =/home/mysql/mysql3308/log/mysql3308_bin
3. Running Mysqld_multi
# start
/usr/local/mysql/bin/mysqld_multi start
# stop
/usr/local/mysql/bin/mysqld_multi stop
# Query Status
/usr/local/mysql/bin/mysqld_multi Report
Nine. mysql database multi-instance installation