Home Database Mysql Tutorial Implementation steps to install two or more mysql on one server_MySQL

Implementation steps to install two or more mysql on one server_MySQL

Oct 09, 2016 am 08:33 AM

How to install two or more mysql on one server? Below are the detailed steps, let’s learn together.

1. Environment

mysql package:

mysql-5.6.31.tar

mysql-5.5.32.tar

Operating system environment:

CentOS release 6.8 (Final)

2. System scale

/mysqlsoft Used to store various programs of mysql
/mysqlsoft/mysql1 Used to store the installation program of mysql-5.5.32.tar
/mysqlsoft/mysql2 Used 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 data of mysql-5.5.32.
/data/mysql2 Used to store data of mysql-5.6.31.

3. Add users and directories

Add user

groupadd mysql

useradd mysql -g mysql
Copy after login

Create directory

mkdir /mysqlsoft

mkdir mysqlsoft/mysql1/ -pv

mkdir mysqlsoft/mysql2/ -pv
Copy after login

Create data directory

mkdir /data

mkdir /data/mysql1/ -pv

mkdir /data/mysql2/ -pv
Copy after login

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
Copy after login

4. Compile mysql and install it

We need to install some tools before compiling and installing the source code

cmake,make,gcc,Perl, 

yum install cmake,make,gcc,Perl -y
Copy after login

4.1 mysql-5.5.32

cd mysqlsoft/mysql1/

tar -zxvf mysql-5.5.32.tar.gz

mkdir bootstarp
Copy after login

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
Copy after login

After compilation, we need to make and then make install

4.2 Work after installation

cd /mysqlsoft/mysql1

cp ./support-files/my-default.cnf my.cnf
Copy after login

Edit my.cnf to add configuration items

chown -R mysql .

chgrp -R mysql .
Copy after login
Copy after login

Initialize mysql:

scripts/mysql_install_db –user=mysql
Copy after login
Copy after login

Change permissions of mysql data directory

4.3 mysql-5.6.31

cd /mysqlsoft/mysql2

tar -zxvf mysql-5.6.31.tar.gz

mkdir bootstarp
Copy after login

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
Copy after login

After compilation, we need to make and then make install

4.4 Post-installation work

cd /mysqlsoft/mysql2

cp ./support-files/my-default.cnf my.cnf
Copy after login

Edit my.cnf to add configuration items

chown -R mysql .

chgrp -R mysql .
Copy after login
Copy after login

Initialize mysql:

scripts/mysql_install_db –user=mysql
Copy after login
Copy after login

Change permissions of mysql data directory

5. Start mysql

5.1 Start mysql-5.5.32

cd /mysqlsoft/mysql1

bin/mysqld_safe –user=mysql &
Copy after login

5.2 Start mysql-5.6.31

cd /mysqlsoft/mysql2

bin/mysqld_safe –user=mysql &
Copy after login

5.3 Check the startup status of mysql

[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
Copy after login

5.4 Delete other items in mysql

1. Change the root user and change the password

2. Delete anonymous users

3. Delete some lines in mysql.db, which define that any user can access the test database, or databases starting with test_.

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

Summary

The above is the entire content of this article. I hope it can be of some help to everyone’s study and work.

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Article Tags

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Reduce the use of MySQL memory in Docker Reduce the use of MySQL memory in Docker Mar 04, 2025 pm 03:52 PM

Reduce the use of MySQL memory in Docker

How do you alter a table in MySQL using the ALTER TABLE statement? How do you alter a table in MySQL using the ALTER TABLE statement? Mar 19, 2025 pm 03:51 PM

How do you alter a table in MySQL using the ALTER TABLE statement?

How to solve the problem of mysql cannot open shared library How to solve the problem of mysql cannot open shared library Mar 04, 2025 pm 04:01 PM

How to solve the problem of mysql cannot open shared library

Run MySQl in Linux (with/without podman container with phpmyadmin) Run MySQl in Linux (with/without podman container with phpmyadmin) Mar 04, 2025 pm 03:54 PM

Run MySQl in Linux (with/without podman container with phpmyadmin)

What is SQLite? Comprehensive overview What is SQLite? Comprehensive overview Mar 04, 2025 pm 03:55 PM

What is SQLite? Comprehensive overview

Running multiple MySQL versions on MacOS: A step-by-step guide Running multiple MySQL versions on MacOS: A step-by-step guide Mar 04, 2025 pm 03:49 PM

Running multiple MySQL versions on MacOS: A step-by-step guide

What are some popular MySQL GUI tools (e.g., MySQL Workbench, phpMyAdmin)? What are some popular MySQL GUI tools (e.g., MySQL Workbench, phpMyAdmin)? Mar 21, 2025 pm 06:28 PM

What are some popular MySQL GUI tools (e.g., MySQL Workbench, phpMyAdmin)?

How do I configure SSL/TLS encryption for MySQL connections? How do I configure SSL/TLS encryption for MySQL connections? Mar 18, 2025 pm 12:01 PM

How do I configure SSL/TLS encryption for MySQL connections?

See all articles