How to install two MySQL or more on a single server

Source: Internet
Author: User

How to install two MySQL on a single server

1 Preface

On a machine on the source code compiled to install a MySQL, then how to compile the source code on a single machine installed two MySQL or more?

2 environment

MySQL Package:

Mysql-5.6.31.tar

Mysql-5.5.32.tar

Operating system Environment:

CentOS Release 6.8 (Final)

3 System Size

/mysqlsoft

The various programs used to store MySQL

/mysqlsoft/mysql1

For storing Mysql-5.5.32.tar

The installation program

/mysqlsoft/mysql2

For storing Mysql-5.6.31.tar

The installation program

/mysqlsoft/mysql1/mysql.sock

/mysqlsoft/mysql2/mysql.sock

/data

Used to store data

/data/mysql1

The data used to store mysql-5.5.32.

/data/mysql2

The data used to store mysql-5.6.31.

4 Adding Users and directories

Add user

Groupadd MySQL

Useradd mysql-g MySQL

Create a Directory

Mkdir/mysqlsoft

mkdir mysqlsoft/mysql1/-PV

mkdir mysqlsoft/mysql2/-PV

Create Data Catalog

Mkdir/data

mkdir/data/mysql1/-PV

mkdir/data/mysql2/-PV

To change permissions:

Chown-r Mysql:mysql MYSQLSOFT/MYSQL1

Chown-r Mysql:mysql MYSQLSOFT/MYSQL2

Chown-r MYSQL:MYSQL/DATA/MYSQL1

Chown-r MYSQL:MYSQL/DATA/MYSQL2

5 Compiling MySQL and installing

We need to install the tool before the source code is compiled and installed.

Cmake,make,gcc,perl,

Yum Install Cmake,make,gcc,perl-y

5.1 mysql-5.5.32

CD mysqlsoft/mysql1/

TAR-ZXVF mysql-5.5.32.tar.gz

mkdir Bootstarp

We compile the source code in the Bootstarp directory.

CMake. -dcmake_install_prefix=/mysqlsoft/mysql1

-dmysql_datadir=/data/mysql1

-dsysconfdir=/mysqlsoft/mysql1

-dwith_innobase_storage_engine=1

-dwith_archive_storage_engine=1

-dwith_blackhole_storage_engine=1

-dwith_perfschema_storage_engine=1

-dmysql_tcp_port=3301

-dmysql_unix_addr=/mysqlsoft/mysql1/mysql.sock

After compiling, we need make and make install

5.2 Post-installation work

Specific reference: http://www.cnblogs.com/karmapeng/p/5844875.html

Cd/mysqlsoft/mysql1

CP./SUPPORT-FILES/MY-DEFAULT.CNF MY.CNF

Edit MY.CNF Add a configuration item

Chown-r MySQL.

Chgrp-r MySQL.

Initialize MySQL:

scripts/mysql_install_db--user=mysql

Change permissions on the MySQL data directory

5.3 mysql-5.6.31

Cd/mysqlsoft/mysql2

TAR-ZXVF mysql-5.6.31.tar.gz

mkdir Bootstarp

We compile the source code in the Bootstarp directory.

CMake. -dcmake_install_prefix=/mysqlsoft/mysql2

-dmysql_datadir=/data/mysql2

-dsysconfdir=/mysqlsoft/mysql2

-dwith_innobase_storage_engine=1

-dwith_archive_storage_engine=1

-dwith_blackhole_storage_engine=1

-dwith_perfschema_storage_engine=1

-dmysql_tcp_port=3302

-dmysql_unix_addr=/mysqlsoft/mysql2/mysql.sock

After compiling, we need make and make install

5.4 Post-installation work

Specific reference: http://www.cnblogs.com/karmapeng/p/5844875.html

Cd/mysqlsoft/mysql2

CP./SUPPORT-FILES/MY-DEFAULT.CNF MY.CNF

Edit MY.CNF Add a configuration item

Chown-r MySQL.

Chgrp-r MySQL.

Initialize MySQL:

scripts/mysql_install_db--user=mysql

Change permissions on the MySQL data directory

6 Start mysql6.1 start mysql-5.5.32

Cd/mysqlsoft/mysql1

Bin/mysqld_safe--user=mysql &

6.2 Start mysql-5.6.31

Cd/mysqlsoft/mysql2

Bin/mysqld_safe--user=mysql &

6.3 Viewing the startup situation of MySQL

[Email protected] mysql2]# Ps-ef | grep MySQL

Root 6329 2853 0 13:19 pts/0 00:00:00/bin/sh bin/mysqld_safe--user=mysql

MySQL 6607 6329 0 13:19 pts/0 00:00:00/mysqlsoft/mysql1/bin/mysqld--basedir=/mysqlsoft/mysql1/--datadir=/data/ mysql1/--plugin-dir=/mysqlsoft/mysql1//lib/plugin--user=mysql--log-error=/data/mysql1//mysql.localdomain.err-- Pid-file=/data/mysql1//mysql.localdomain.pid--socket=/mysqlsoft/mysql1/mysql.sock--port=3301

Root 6630 2853 0 13:20 pts/0 00:00:00/bin/sh bin/mysqld_safe--user=mysql

MySQL 6774 6630 0 13:20 pts/0 00:00:00/mysqlsoft/mysql2/bin/mysqld--basedir=/mysqlsoft/mysql2--datadir=/data/m YSQL2--plugin-dir=/mysqlsoft/mysql2/lib/plugin--user=mysql--log-error=/data/mysql2/mysql.localdomain.err-- Pid-file=/data/mysql2/mysql.localdomain.pid--socket=/mysqlsoft/mysql2/mysql.sock--port=3302

6.4 Delete Other items in MySQL

1. Change the password for the root user

2. Delete anonymous users

3. Delete some rows in the mysql.db that define the database to which any user can access the test database, or start with Test_.

DELETE from mysql.db WHERE db like ' test% ';

For details, please refer to

Http://www.cnblogs.com/karmapeng/p/5844875.html

How to install two MySQL or more 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.