Install multiple MySql 5.7 in Centos
① extract the downloaded version of MySql installation package
② installation script writing
③ script and installation package will be placed in the same directory
④ written my.cnf file and placed in the / etc / directory
⑤ given permission to run the script and run
⑥ modify the default password
① download MySql extract the installation package version
click portal: MySql MySql Download the corresponding system, choose Centos Linux - Generic <64 digits> (I Centos is a 64-bit, 32-bit, please choose 32)
② installation script writing
! # / bin / bash baseMysqlDir = / usr / local / tarsPkg / mysql- 5.7 . 22 . -linux-glibc2 12 - x86_64 yum install mysql- devel ## MySQL create a soft link LN -s $ {baseMysqlDir} / usr / local / mysql ## to create a MySQL user useradd -r -s / sbin / nologin mysql ## created in the MySQL binary packages mysql directory - Files directory mkdir -v / usr / local / mysql / mysql- Files ## Creating a multi-instance data directory mkdir -vp / Data / {mysql_data . 1 .. . 4 } ## MySQL binary modify their user directory packet belonging group chownroot.mysql - R & lt baseMysqlDir} {$ ## MySQL modified multi-instance data catalog data import / relevant to the user and exported special place directory belonging group chown mysql.mysql -R & lt / usr / local / MySQL / MySQL-Files / Data / {mysql_data . 1 .. . 4 } various examples ## initialization [initialization is complete with a random password will output log] / usr / local / MySQL / bin / MySQL --basedir mysqld --initialize --user = = / usr / local / MySQL --datadir = / Data / mysql_data1 / usr / local / MySQL / bin / MySQL --basedir mysqld --initialize --user = = / usr / local / MySQL --datadir = / Data / mysql_data2 / usr / local / MySQL / bin / MySQL --basedir mysqld --initialize --user = = / usr / local / MySQL --datadir = / Data / mysql_data3 / usr / local / MySQL / bin / mysqld --user --initialize = mysql --basedir = / usr / local / mysql --datadir = / data /mysql_data4 ## connected to each of Examples Open SSL / usr / local / MySQL / bin / MySQL --basedir mysql_ssl_rsa_setup --user = = / usr / local / MySQL --datadir = / Data / mysql_data1 / usr / local / MySQL / bin / --user = MySQL --basedir = mysql_ssl_rsa_setup / usr / local / MySQL --datadir = / Data / mysql_data2 / usr / local / MySQL / bin / MySQL --basedir mysql_ssl_rsa_setup --user = = / usr / local / MySQL - = -datadir / Data / mysql_data3 / usr / local / mysql / bin / mysql_ssl_rsa_setup --basedir --user = mysql = / usr / local / mysql --datadir = / Data / mysql_data4 ## to add mysql path echo " the pATH = / usr / local / MySQL / bin: $ the PATH " >> / etc / Profile Source / etc / Profile ## copy the script to the next multi-instance management services directory [/etc/init.d/ ] cp /usr/local/mysql/support-files/mysqld_multi.server /etc/init.d/ mysqld_multi ## adding scripts execute permissions chmod + the X-/etc/init.d/ mysqld_multi ## add service service management chkconfig - the Add mysqld_multi Export the PATH = / usr / local / MySQL / bin: the PATH $ ## check more than one instance of state /etc/init.d/ mysqld_multi Report
③ scripts and installation packages are placed in the same directory
Write ④ my.cnf file and placed in the / etc / directory
[the mysqld_multi] mysqld = / usr / local / MySQL / bin / mysqld mysqladmin = / usr / local / MySQL / bin / mysqladmin log = / tmp / mysql_multi.log [mysqld1] Federated # Set data directory [multiple instances must be different ] datadir = / the Data / mysql_data1 # set sock to store the file name [multi-instance must be different] socket = / tmp / mysql.sock1 # set listening port open [multi-instance must be different] port = 3306 # set to run user user = MySQL # close monitoring performance_schema = OFF # set innodb buffer size innodb_buffer_pool_size = 32M # 设置监听IP地址 bind_address = 0.0.0.0 # 关闭DNS 反向解析 skip-name-resolve = 0 max_connections=1000 sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES explicit_defaults_for_timestamp=true tmpdir=/data/mysql_data1 character_set_server = utf8mb4 [mysqld2] datadir = /data/mysql_data2 socket = /tmp/mysql.sock2 tmpdir=/data/mysql_data2 port = 3307 user = mysql performance_schema = off innodb_buffer_pool_size = 32M bind_address = 0.0.0.0 skip-name-resolve = 0 sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES explicit_defaults_for_timestamp=true lower_case_table_names = 1 [mysqld3] datadir = /data/mysql_data3 socket = /tmp/mysql.sock3 tmpdir=/data/mysql_data3 port = 3308 user = mysql performance_schema = off innodb_buffer_pool_size = 32M bind_address = 0.0.0.0 skip-name-resolve = 0 sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES explicit_defaults_for_timestamp=true lower_case_table_names = 1 [mysqld4] datadir = /data/mysql_data4 socket = /tmp/mysql.sock4 tmpdir=/data/mysql_data4 port = 3309 user = mysql performance_schema = off innodb_buffer_pool_size = 32M bind_address = 0.0.0.0 skip-name-resolve = 0 sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES explicit_defaults_for_timestamp=true
⑤ given permission to run the script and run
Results of the:
⑥ change the default password
Remember modify the default password each oh