Install two or more mysql implementation steps on one server and one mysql

Source: Internet
Author: User

Install two or more mysql implementation steps on one server and one mysql

How can I install two or more mysql instances on one server? The following are detailed steps for learning.

I. Environment

Mysql software package:

Mysql-5.6.31.tar

Mysql-5.5.32.tar

Operating system environment:

CentOS release 6.8 (Final)

Ii. System scale

/Mysqlsoft Used to store various mysql programs
/Mysqlsoft/mysql1 To store the installation program of mysql-5.5.32.tar.
/Mysqlsoft/mysql2 To store the installation program of mysql-5.6.31.tar.
/Mysqlsoft/mysql1/mysql. sock
/Mysqlsoft/mysql2/mysql. sock
/Data Used to store data
/Data/mysql1 Used to store mysql-5.5.32. Data
/Data/mysql2 Used to store mysql-5.6.31. Data

3. Add users and directories

Add User

groupadd mysqluseradd mysql -g mysql

Create directory

mkdir /mysqlsoftmkdir mysqlsoft/mysql1/ -pvmkdir mysqlsoft/mysql2/ -pv

Create a data directory

mkdir /datamkdir /data/mysql1/ -pvmkdir /data/mysql2/ -pv

Change permissions:

chown -R mysql:mysql mysqlsoft/mysql1chown -R mysql:mysql mysqlsoft/mysql2chown -R mysql:mysql /data/mysql1chown -R mysql:mysql /data/mysql2

4. Compile and install mysql

Install the tool before compiling and installing the source code.

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.gzmkdir 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 compilation, we needmakeThenmake install

4.2 Post-installation work

cd /mysqlsoft/mysql1cp ./support-files/my-default.cnf my.cnf

Edit my. cnf to add configuration items

chown -R mysql .chgrp -R mysql .

Initialize mysql:

scripts/mysql_install_db –user=mysql

Change mysql Data Directory Permissions

4.3 mysql-5.6.31

cd /mysqlsoft/mysql2tar -zxvf mysql-5.6.31.tar.gzmkdir 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 compilation, we needmakeThenmake install

4.4 Post-installation work

cd /mysqlsoft/mysql2cp ./support-files/my-default.cnf my.cnf

Edit my. cnf to add configuration items

chown -R mysql .chgrp -R mysql .

Initialize mysql:

scripts/mysql_install_db –user=mysql

Change mysql Data Directory Permissions

V. Start mysql

5.1 start mysql-5.5.32

cd /mysqlsoft/mysql1bin/mysqld_safe –user=mysql &

5.2 start mysql-5.6.31

cd /mysqlsoft/mysql2bin/mysqld_safe –user=mysql &

5.3 view mysql startup status

[root@mysql mysql2]# ps -ef | grep mysqlroot   6329 2853 0 13:19 pts/0  00:00:00 /bin/sh bin/mysqld_safe –user=mysqlmysql   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=3301root   6630 2853 0 13:20 pts/0  00:00:00 /bin/sh bin/mysqld_safe –user=mysqlmysql   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 of the root user

2. Delete Anonymous Users

3. delete some rows in mysql. db, which define that any user can access the test database or a database starting with test.

DELETE FROM mysql.db WHERE Db LIKE ‘test%';

Summary

The above is all about this article, hoping to help you in your study and work.

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.