2 MySQL services on a single server

Source: Internet
Author: User
Tags uuid

Add a group, adding users to the group, unzip

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

MV mysql-5.6.23-linux-glibc2.5-x86_64/mnt/sda4/mysql5.6.23

MV 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

Two. Default initialization path

/usr/local/mysql/scripts/mysql_install_db--user=mysql--basedir=/usr/local/mysql--datadir=/usr/local/mysql/data

Secure boot

/usr/local/mysql/bin/mysqld_safe--defaults-file=/etc/my.cnf This way can not be closed after startup, you must kill manually

Using Startup scripts

Cp/usr/local/mysql/support-files/mysql.server/etc/init.d/mysqld will be able to service MySQL Stop|start|restart.

Three. mysql5.6.23 version

Change the file mysqld_safe,mysql.server,mysqld_multi.server,mysql-log-rotate inside/usr/local/mysql to/mnt/sda4/mysql5.6.23. 5.7.9 version changed to/mnt/sda4/mysql5.7.9

/mnt/sda4/mysql5.6.23/bin/mysqld_safe the/tmp/mysql.sock in this file---->/tmp/mysql5.6.23.sock 5.7.9 Version 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

Vim inside both%s/\/usr\/local\/mysql/\/mnt\/sda4\/mysql5.6.23/g

Four. Modify permissions, configuration files

Chown-r mysql:mysql/mnt/sda4/mysql5.6.23

[Email protected] ~]# 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 = 16M

Max_allowed_packet = 1M

Table_open_cache = 64

Sort_buffer_size = 512K

Net_buffer_length = 8K

Read_buffer_size = 256K

Read_rnd_buffer_size = 512K

Myisam_sort_buffer_size = 8M

Max_allowed_packet = 4M

max_connections=2000

Innodb_buffer_pool_size = 3G

Innodb_log_buffer_size = 256M

Sql_mode=no_engine_substitution,strict_trans_tables

Five. Make the 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 Test is able to start

cp/mnt/sda4/mysql5.6.23/support-files/mysql.server/etc/init.d/mysql5.6.23

So you can service MySQL Stop|start|restart.

Six. mysql5.7.9 version initialization

Here to notice MySQL5.7.6 after shielding mysql_install_db can only select MySQL--initialize to install

Configuration profiles for 5.7.9

[Email protected] ~]# CAT/ETC/MY5.7.9.CNF

[Mysqld]

Basedir =/mnt/sda4/mysql5.7.9

DataDir =/mnt/sda4/mysql5.7.9/data

port=3307 <---Define and 5.6.23 different port numbers 3307

Socket=/tmp/mysql.sock

Bind-address = 0.0.0.0

Skip-external-locking

Key_buffer_size = 16M

Max_allowed_packet = 1M

Table_open_cache = 64

Sort_buffer_size = 512K

Net_buffer_length = 8K

Read_buffer_size = 256K

Read_rnd_buffer_size = 512K

Myisam_sort_buffer_size = 8M

Max_allowed_packet = 4M

max_connections=2000

Innodb_buffer_pool_size = 3G

Innodb_log_buffer_size = 256M

Sql_mode=no_engine_substitution,strict_trans_tables

Seven. Perform initialization and test startup scripts

/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

[Email protected] 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. --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 Should is used with strict mode. They'll is merged with strict mode in a future release.

2015-11-19t14:40:52.540816z 0 [Warning] ' no_auto_create_user ' SQL mode is 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 have been found, so we assume that's the first time that thi s server has been started. Generating a new uuid:8a648e5a-8ecb-11e5-911c-0050569c4b72.

2015-11-19t14:40:55.630337z 0 [Warning] Gtid table is not a 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 [email protected]: ZE:OCYH) U1&y <------ Random password

[Email protected] 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 was 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

Eight. View the started process

[[Email protected] ~]# PS aux |grep mysql

Root 30783 0.0 0.0 66064 1336 PTS/4 S 23:02 0:00/bin/sh/mnt/sda4/mysql5.7.9/bin/mysqld_safe--datadir=/m Nt/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 23:02 0:00/mnt/sda4/mysql5.7.9/bin/mysqld--basedir=/mnt/sda4/mysql 5.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 23:02 0:00/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 1217628 pts/4 Sl 23:02 0:01/mnt/sda4/mysql5.6.23/bin/mysqld--basedir=/mnt/sda4/mysq l5.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+ 23:04 0:00 grep mysql

Nine. 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

mysql5.7.9 Change Password

/mnt/sda4/mysql5.7.9/bin

[Email protected] bin]#/mysqladmin-uroot-p3307-h127.0.0.1-p password

This article from "Running" blog, declined reprint!

2 MySQL services on a single server

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.