Two MySQL services run on one server
Two MySQL services run on one server
1. Add a group, add a user to the group, and decompress the package.
Groupadd mysql
Useradd mysql-g mysql-M-s/sbin/nologin
Tar-zxvf mysql-5.6.23-linux-glibc2.5-x86_64.tar.gz
Tar-zxvf mysql-5.7.9-linux-glibc2.5-x86_64.tar.gz
Music mysql-5.6.23-linux-glibc2.5-x86_64/mnt/sda4/mysql5.6.23
Music mysql-5.7.9-linux-glibc2.5-x86_64/mnt/sda4/mysql65.7.9
Mkdir-p/mnt/sda4/mysql5.6.23/data
Mkdir-p/mnt/sda4/mysql5.7.9/data
2. Default initialization path
/Usr/local/mysql/scripts/mysql_install_db -- user = mysql -- basedir =/usr/local/mysql -- datadir =/usr/local/mysql/data
Secure startup
/Usr/local/mysql/bin/mysqld_safe -- defaults-file =/etc/my. cnf cannot be closed after it is started. You must manually kill it.
Use the Startup Script
Cp/usr/local/mysql/support-files/mysql. server/etc/init. d/mysqld, you can use service mysql stop | start | restart.
Iii. MySQL 5.6.23
Change/usr/local/mysql in mysqld_safe, mysql. server, mysqld_multi.server, and mysql-log-rotate to/mnt/sda4/mysql5.6.23. Version 5.7.9 to/mnt/sda4/mysql5.7.9
/Mnt/sda4/mysql5.6.23/bin/mysqld_safe change/tmp/mysql. sock ---->/tmp/mysql5.6.23.sock 5.7.9 in this file to/tmp/mysql5.7.9.sock
/Mnt/sda4/mysql5.6.23/support-files/mysql. server
/Mnt/sda4/mysql5.7.9/support-files/mysqld_multi.server
/Mnt/sda4/mysql5.7.9/support-files/mysql-log-rotate
In vim, % s/\/usr \/local \/mysql/\/mnt \/sda4 \/mysql5.6.23/g
4. Modify permissions and configuration files
Chown-R mysql: mysql/mnt/sda4/mysql5.6.23
[Root @ sam ~] # Cat/etc/my5.6.23.cnf
[Mysqld]
Basedir =/mnt/sda4/mysql5.6.23
Datadir =/mnt/sda4/mysql5.6.23/data
Port = 3306
Socket =/tmp/mysql. sock
Bind-address = 0.0.0.0
Skip-external-locking
Key_buffer_size = 16 M
Max_allowed_packet = 1 M
Table_open_cache = 64
Sort_buffer_size = 512 K
Net_buffer_length = 8 K
Read_buffer_size = 256 K
Read_rnd_buffer_size = 512 K
Myisam_sort_buffer_size = 8 M
Max_allowed_packet = 4 M
Max_connections = 2000
Innodb_buffer_pool_size = 3G
Innodb_log_buffer_size = 256 M
SQL _mode = NO_ENGINE_SUBSTITUTION, STRICT_TRANS_TABLES
5. make corresponding changes
/Mnt/sda4/mysql5.6.23/scripts/mysql_install_db -- user = mysql -- basedir =/mnt/sda4/mysql5.6.23 -- datadir =/mnt/sda4/mysql5.6.23/data
/Mnt/sda4/mysql5.6.23/bin/mysqld_safe -- defaults-file =/etc/my5.6.23.cnf
Cp/mnt/sda4/mysql5.6.23/support-files/mysql. server/etc/init. d/mysql5.6.23
In this way, you can use service mysql stop | start | restart.
Vi. mysql5.7.9 Initialization
Note that MySQL5.7.6 and later are blocked. Only mysql -- initialize can be selected for installation.
5.7.9 configuration file
[Root @ sam ~] # Cat/etc/my5.7.9.cnf
[Mysqld]
Basedir =/mnt/sda4/mysql5.7.9
Datadir =/mnt/sda4/mysql5.7.9/data
Port = 3307 <--- Define port number 3307 different from 5.6.23
Socket =/tmp/mysql. sock
Bind-address = 0.0.0.0
Skip-external-locking
Key_buffer_size = 16 M
Max_allowed_packet = 1 M
Table_open_cache = 64
Sort_buffer_size = 512 K
Net_buffer_length = 8 K
Read_buffer_size = 256 K
Read_rnd_buffer_size = 512 K
Myisam_sort_buffer_size = 8 M
Max_allowed_packet = 4 M
Max_connections = 2000
Innodb_buffer_pool_size = 3G
Innodb_log_buffer_size = 256 M
SQL _mode = NO_ENGINE_SUBSTITUTION, STRICT_TRANS_TABLES
7. Execute initialization and test the Startup Script
/Mnt/sda4/mysql5.7.9/bin/mysqld -- defaults-file =/etc/my5.7.9.cnf -- initialize
/Mnt/sda4/mysql5.7.9/bin/mysqld_safe -- defaults-file =/etc/my5.7.9.cnf
[Root @ sam bin] #./mysqld -- defaults-file =/etc/my5.7.9.cnf -- initialize
2015-11-19T14: 40: 52.540335Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use -- explicit_defaults_for_timestamp server option (see documentation for more details ).
2015-11-19T14: 40: 52.540810Z 0 [Warning] 'No _ ZERO_DATE ', 'no _ ZERO_IN_DATE' and 'error _ FOR_DIVISION_BY_ZERO 'SQL modes shocould be used with strict mode. they will be merged with strict mode in a future release.
2015-11-19T14: 40: 52.540816Z 0 [Warning] 'No _ AUTO_CREATE_USER 'SQL mode was not set.
2015-11-19T14: 40: 55.180025Z 0 [Warning] InnoDB: New log files created, LSN = 45790
2015-11-19T14: 40: 55.500690Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2015-11-19T14: 40: 55.601943Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: login.
2015-11-19T14: 40: 55.630337Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql. gtid_executed' cannot be opened.
2015-11-19T14: 40: 55.631059Z 1 [Note] A temporary password is generated for root @ localhost: ze: OCyh) U1 & y <------ Random password
[Root @ sam bin] #./mysqld_safe -- defaults-file =/etc/my5.7.9.cnf
151119 22:42:26 mysqld_safe Logging to '/mnt/sda4/mysql5.7.9/data/sam.adsame.com. err '.
151119 22:42:26 mysqld_safe The file/usr/local/mysql/bin/mysqld
Does not exist or is not executable. Please cd to the mysql installation
Directory and restart this script from there as follows:
./Bin/mysqld_safe &
See http://dev.mysql.com/doc/mysql/en/mysqld-safe.html for more information
8. View started processes
[Root @ sam ~] # Ps aux | grep mysql
Root 30783 0.0 0.0 66064 1336 pts/4 S/bin/sh/mnt/sda4/mysql5.7.9/bin/mysqld_safe -- datadir =/mnt/sda4/mysql5.7.9/data -- pid- file =/mnt/sda4/mysql5.7.9/data/sam.adsame.com. pid
Mysql 31110 0.5 10.2 4504488 414676 pts/4 Sl/mnt/sda4/mysql5.7.9/bin/mysqld -- basedir =/mnt/sda4/mysql5.7.9 -- datadir =/mnt/sda4/mysql5.7.9 /data -- plugin-dir =/mnt/sda4/mysql5.7.9/lib/plugin -- user = mysql -- log-error =/mnt/sda4/mysql5.7.9/data/sam.adsame.com. err -- pid-file =/mnt/sda4/mysql5.7.9/data/sam.adsame.com. pid -- socket =/tmp/mysql5.7.9.sock -- port = 3307
Root 31169 0.0 0.0 65932 1336 pts/4 S/bin/sh/mnt/sda4/mysql5.6.23/bin/mysqld_safe -- datadir =/mnt/sda4/mysql5.6.23/data -- pid- file =/mnt/sda4/mysql5.6.23/data/sam.adsame.com. pid
Mysql 31732 1.0 30.1 4601900 pts/4 Sl/mnt/sda4/mysql5.6.23/bin/mysqld -- basedir =/mnt/sda4/mysql5.6.23 -- datadir =/mnt/sda4/mysql5.6.23 /data -- plugin-dir =/mnt/sda4/mysql5.6.23/lib/plugin -- user = mysql -- log-error =/mnt/sda4/mysql5.6.23/data/sam.adsame.com. err -- pid-file =/mnt/sda4/mysql5.6.23/data/sam.adsame.com. pid -- socket =/tmp/mysql5.6.23.sock -- port = 3306
Root 31770 0.0 0.0 61160 740 pts/1 S + grep mysql
9. Client Connection
/Mnt/sda4/mysql5.6.23/bin/mysql-uroot-P3306-h127.0.0.1
/Mnt/sda4/mysql5.7.9/bin/mysql-uroot-P3307-h127.0.0.1
Change Password in mysql5.7.9
/Mnt/sda4/mysql5.7.9/bin
[Root @ sam bin] #./mysqladmin-uroot-P3307-h127.0.0.1-p password
This article permanently updates the link address: