Due to temporary requirements, you need to start multiple mysql instances on one host, corresponding to different ports. Step 1: Install mysql. 2. Set the configuration files for different instances. 3. Create datadir for different instances and perform database initialization. 4. To start different mysql instances, you need to start multiple mysql instances on one host, corresponding to different ports.
The procedure is as follows:
1. Install mysql.
2. Set the configuration files for different instances.
3. Create datadir for different instances and perform database initialization.
4. Start different mysql instances.
The installation method is as follows:
1. Install mysql
Use the source code for installation.
tar -zxvf mysql-5.5.49.tar.gz cd mysql-5.5.49mkdir /usr/local/mysqlcmake - -DCMAKE_INSTALL_PREFIX=/usr/local/mysqlmakemake install
2. Set my. cnf first.
Cp support-files/my-medium.cnf/etc/my. cnf chown mysql: mysql-R/usr/local/mysql /. /scripts/mysql_install_db -- user = mysql -- basedir =/usr/local/mysql -- datadir =/dbdata/mysql/data initialize the database
3. Set different directory files
mkdir -p /dbdata/{3307,3308,3309}/datacp /etc/my.cnf /dbdata/3307/cp /etc/my.cnf /dbdata/3308/cp /etc/my.cnf /dbdata/3309/vim /dbdata/3307/my.cnf ++++++++++++++++++[client]port = 3307socket = /dbdata/3307/mysql.sock[mysqld]port = 3307socket = /dbdata/3307/mysql.sockskip-external-lockingkey_buffer_size = 16Mmax_allowed_packet = 1Mtable_open_cache = 64sort_buffer_size = 512Knet_buffer_length = 8Kread_buffer_size = 256Kread_rnd_buffer_size = 512Kmyisam_sort_buffer_size = 8Mskip-name-resolvebasedir = /usr/local/mysqldatadir = /dbdata/3307/datalog-bin=mysql-binbinlog_format=mixedserver-id = 1[mysqldump]quickmax_allowed_packet = 16M[mysql]no-auto-rehash[myisamchk]key_buffer_size = 20Msort_buffer_size = 20Mread_buffer = 2Mwrite_buffer = 2M[mysqlhotcopy]interactive-timeout[mysqld_safe]log-error=/dbdata/3307/3307.errpid-file=/dbdata/3307/3307.pid
Modify the configuration files of port 3308 and port 3309 respectively.
4. initialize startup
/Usr/local/mysql/scripts/mysql_install_db -- basedir =/usr/local/mysql -- datadir =/dbdata/3307/data -- user = mysql/usr/local/mysql/scripts /mysql_install_db -- basedir =/usr/local/mysql -- datadir =/dbdata/3308/data -- user = mysql/usr/local/mysql/scripts/mysql_install_db -- basedir =/usr/ local/mysql -- datadir =/dbdata/3309/data -- user = mysql startup: /usr/local/mysql/bin/mysqld_safe -- defaults-file =/dbdata/3307/my. cnf &/usr/local/mysql/bin/mysqld_safe -- defaults-file =/dbdata/3308/my. cnf &/usr/local/mysql/bin/mysqld_safe -- defaults-file =/dbdata/3309/my. cnf & login: mysql-uroot-p-S/dbdata/3308/mysql. sock password Change mysqladmin-uroot-p password 123456-S/dbdata/3307/mysql. sock
Complete.