To install two or more Mysql implementation steps on a single server _mysql

Source: Internet
Author: User

How do you install two or more MySQL on a single server? Below is the detailed procedure, together to learn to learn.

First, the environment

MySQL Package:

Mysql-5.6.31.tar

Mysql-5.5.32.tar

Operating system Environment:

CentOS Release 6.8 (Final)

Ii. scale of the system

/mysqlsoft The procedures used to store MySQL
/mysqlsoft/mysql1 Installer for storing Mysql-5.5.32.tar
/mysqlsoft/mysql2 Installer for storing Mysql-5.6.31.tar
/mysqlsoft/mysql1/mysql.sock
/mysqlsoft/mysql2/mysql.sock
/data For storing data.
/data/mysql1 The data used to store mysql-5.5.32.
/data/mysql2 The data used to store mysql-5.6.31.

Third, add Users and directories

Add user

Groupadd MySQL

useradd mysql-g MySQL

Create a table of contents

Mkdir/mysqlsoft

mkdir mysqlsoft/mysql1/-pv

mkdir mysqlsoft/mysql2/

Create a Data directory

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<

C11/>chown-r MYSQL:MYSQL/DATA/MYSQL2

Four, compile MySQL and install

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

Cmake,make,gcc,perl, 

yum install cmake,make,gcc,perl-y

4.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 to make thenmake install

4.2 Post-installation work

CD/MYSQLSOFT/MYSQL1

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

Edit MY.CNF Add Configuration item

Chown-r MySQL.

Chgrp-r MySQL.

Initialize MySQL:

Scripts/mysql_install_db–user=mysql

Change permissions for MySQL data directory

4.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 to make thenmake install

4.4 Post-installation work

CD/MYSQLSOFT/MYSQL2

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

Edit MY.CNF Add Configuration item

Chown-r MySQL.

Chgrp-r MySQL.

Initialize MySQL:

Scripts/mysql_install_db–user=mysql

Change permissions for MySQL data directory

Five, start MySQL

5.1 Start mysql-5.5.32

CD/MYSQLSOFT/MYSQL1

Bin/mysqld_safe–user=mysql &

5.2 Start mysql-5.6.31

CD/MYSQLSOFT/MYSQL2

Bin/mysqld_safe–user=mysql &

5.3 View the MySQL startup situation

[Root@mysql 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/mysql2–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

5.4 Delete Other items in MySQL

1. Change the password by changing the root user

2. Delete anonymous users

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

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

Summarize

The above is the entire content of this article, I hope for everyone's study and work can bring certain help.

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.