MySQL multiport multi-instance operation implemented under Linux

Source: Internet
Author: User

Statement

The Stars last night

Blog:http://yestreenstars.blog.51cto.com/

This article by oneself creation, if need reprint, please indicate source, thank cooperation!

Objective

MySQL multi-port multiple instance running under Linux.

Main operation

Create a/ETC/MY_MULTI.CNF file

Vi/etc/my_multi.cnf

The content is as follows ( Note!) If your MySQL is installed by source code, change the mysqld and mysqladmin as appropriate, and pay attention to changing the root password. )

[MYSQLD_MULTI]MYSQLD =/usr/bin/mysqld_safemysqladmin =/usr/bin/mysqladminlog =/var/log/mysqld_multi.loguser = Rootpassword = Redhat[mysqld1]user = Mysqlport = 3307datadir =/data1pid-file =/data1/mysqld.pidsocket =/data1/mysql.soc K[mysqld2]user = Mysqlport = 3308datadir =/data2pid-file =/data2/mysqld.pidsocket =/data2/mysql.sock

Create Data Catalog ( Note!) Please create it based on what you actually configured in the/etc/my_multi.cnf file. )

Mkdir/data1chown mysql:mysql/data1mysql_install_db--datadir=/data1mkdir/data2chown Mysql:mysql/data2mysql_ install_db--datadir=/data2

Attention! You can also copy the data directory of the existing database directly, but pay attention to the configuration of the permissions.

Start all DB instances

Mysqld_multi--defaults-extra-file=/etc/my_multi.cnf Start

Configure the same root password for each database (as in/etc/my_multi.cnf)

Mysqladmin-s/data1/mysql.sock-uroot password redhatmysqladmin-s/data1/mysq2.sock-uroot password Redhat

This is the end of the entire configuration.

Related content

# log path/var/log/mysqld_multi.log# start all DB instances Mysqld_multi--defaults-extra-file=/etc/my_multi.cnf start# Stop all DB instances Mysqld_multi--defaults-extra-file=/etc/my_multi.cnf stop# start only one DB instance Mysqld_multi--defaults-extra-file=/ ETC/MY_MULTI.CNF Start # Only stops a DB instance Mysqld_multi--defaults-extra-file=/etc/my_multi.cnf Stop # to connect to the database based on the port Mysql-s/ Data1/mysql.sock-uroot-p


This article is from the "Last Night Stars" blog, please make sure to keep this source http://yestreenstars.blog.51cto.com/1836303/1619294

MySQL multiport multi-instance operation implemented under Linux

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.