mysql-5.6.x Multi-instance configuration

Source: Internet
Author: User

Prerequisite Preparation

Do the test or the use of binary installation, simple and fast, in the original environment to install a good foundation.
mysql-5.6.x binary version installation record http://koumm.blog.51cto.com/703525/1762167
Individuals do not like to use Mysqlmulti mode to configure multi-instance, or multi-instance multi-process mode configuration.

1. Prepare the DB instance DataDir directory

# mkdir-p/usr/local/mysql/mysql3307
# chown mysql:mysql/usr/local/mysql/mysql3307

Initializing the instance directory
#/usr/local/mysql/scripts/mysql_install_db--user=mysql--basedir=/usr/local/mysql--datadir=/usr/local/mysql/ mysql3307

2. Preparing the configuration file

(1) Modify the existing configuration file name My.cnf 3306.cnf, and copy a profile named 3307.cnf
(2) 3306.CNF configuration file modification, port, sock position, PID position, datadir position, etc.

[Client]
Port = 3306
Socket =/tmp/mysql3306.sock

[Mysqld]
Port = 3306
Socket =/tmp/mysql3306.sock
DataDir =/usr/local/mysql/data


(3) 3307.CNF configuration file modification

[Client]
Port = 3307
Socket =/tmp/mysql3307.sock

[Mysqld]
Port = 3307
Socket =/tmp/mysql3307.sock
DataDir =/usr/local/mysql/mysql3307

3. Start a multi-instance, the startup script can be added to the boot file.

/usr/local/mysql/bin/mysqld_safe--defaults-file=/etc/3306.cnf 2>&1 >/dev/null &
/usr/local/mysql/bin/mysqld_safe--defaults-file=/etc/3307.cnf 2>&1 >/dev/null &

4. Database Login

#/usr/local/mysql/bin/mysql-u Root-p-P 3306-s/tmp/mysql3306.sock
#/usr/local/mysql/bin/mysql-u Root-p-P 3307-s/tmp/mysql3307.sock

To modify the 3307 instance password:
#/usr/local/mysql/bin/mysqladmin-u root password ' admin '-s/tmp/mysql3307.sock #设置管理员密码

3306 Login Example 1:

[Email protected] ~]# mysql-uroot-p-s/tmp/mysql3306.sock
Enter Password:
Welcome to the MySQL Monitor. Commands End With; or \g.
Your MySQL Connection ID is 14
Server Version:5.6.24-log Source Distribution

Copyright (c), Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of the Oracle Corporation and/or its
Affiliates. Other names trademarks of their respective
Owners.

Type ' help ', ' or ' \h ' for help. Type ' \c ' to clear the current input statement.

Mysql>
Mysql> \q
Bye

3307 Login Example:

[Email protected] ~]# mysql-uroot-p-s/tmp/mysql3307.sock
Enter Password:
Welcome to the MySQL Monitor. Commands End With; or \g.
Your MySQL Connection ID is 15
Server Version:5.6.24-log Source Distribution

Copyright (c), Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of the Oracle Corporation and/or its
Affiliates. Other names trademarks of their respective owners.

Type ' help ', ' or ' \h ' for help. Type ' \c ' to clear the current input statement.

Mysql>

5. Turn off MySQL multi-instance mode

#/usr/local/mysql/bin/mysqladmin-u Root-p-P 3306-s/tmp/mysql3306.sock shutdown
#/usr/local/mysql/bin/mysqladmin-u Root-p-P 3307-s/tmp/mysql3307.sock shutdown

Or use kill mode, or write a startup script.

This article is from the "Koumm Linux Technology blog" blog, be sure to keep this source http://koumm.blog.51cto.com/703525/1762727

mysql-5.6.x Multi-instance configuration

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.