MySQL Multi-instance run

Source: Internet
Author: User


MySQL implements a server in multiple instances, running MySQL with different data files on different ports , which are independent of each other.

1  

2 , copy, or create a data file

#Copy the existingMySQLDatabase Files#Mine's in/var/lib/mysql, copy one tomysql_3307folder[email protected] ~]#CP-r/var/lib/mysql/var/lib/mysql_3307

# create a new, empty database [email protected] ~]# mkdir /var/lib/mysql_3307[[email protected] ~]# mysql_install_db--datadir=/var/lib/mysql_3307--user=mysql

3

[email protected] ~]# Chown - R mysql.mysql/var/lib/mysql_3307

4, creatingMultithe configurationCNFfile,used to start thisMySQLinstances, such as3307) Load Execution

[email protected] ~]# Touch /usr/local/my_multi.cnf

write the configuration you want in the file, as follows Typical configuration:


[Mysqld_multi]

Mysqld =/usr/bin/mysqld_safe

Mysqladmin =/usr/bin/mysqladmin

user = root

Password = 123456


[mysqld3307]

Socket =/tmp/mysql_3307.sock

Port = 3307

Pid-file =/var/lib/mysql_3307/3307.pid

DataDir =/var/lib/mysql_3307/

Log =/var/lib/mysql_3307/3307.log

Character-set-server = UTF8

user = MySQL

 5 , start your multi-instance

[email protected] ~]# mysqld_multi--defaults-extra- file =/usr/local/my_multi.cnf Start 3307

6 , check whether the start is successful

[[Email protected] Desktop]# netstat-natup |grep MySQL

TCP 0 0 0.0.0.0:3307 0.0.0.0:* LISTEN 3450/mysqld

If you don't find the port number you wantMySQLinstance, you can check the next/var/lib/mysql_3307/3307. Logfile,Troubleshoot issues

7 , set a new password

[email protected] ~]# mysqladmin-uroot-s/tmp/mysql_3307.sock password 123456

8 , log in to your new instance

[[email protected] ~] #mysql-uroot-s/tmp/mysql_3307.sock-p
Enter Password: 123456

650) this.width=650 "Height=" "src=" http://a1.qpic.cn/psb?/v13tfvpi1vswaw/he3jbcr.gwibnlz*ln0vawb9vgexnnprxdznvf3qpcy!/b/ doqaaaaaaaaa&ek=1&kp=1&pt=0&bo=vwnsaqaaaaafapi!&t=5&su=0193890225&tm=1492138800 &sce=0-12-12&rf=2-9 "width=" 870 "style=" margin:0px;padding:0px;border-width:0px;border-style:none; Vertical-align:top;width:847px;height:321.276px;float:left; "Alt=" doqaaaaaaaaa&ek=1&kp=1&pt=0& Bo=vwnsaqaaa "/>
 

again confirm that this instance of yours is not used mysql_3307 The data for this folder

650) this.width=650; "height=" 195 "src=" http://a3.qpic.cn/psb?/v13tfvpi1vswaw/6ncrwozttla9yspqq5tnikssic6* zepdaelashx5kno!/b/daobaaaaaaaa&ek=1&kp=1&pt=0&bo=ewldaaaaaaafape!&t=5&su=0176480945 &tm=1492138800&sce=0-12-12&rf=2-9 "width=" 531 "style=" margin:0px;padding:0px;border-width:0px; border-style:none;vertical-align:top; "alt=" Daobaaaaaaaa&ek=1&kp=1&pt=0&bo=ewldaaaaa "/>

A new instance has been found to have started up.
Then we start the original instance: service mysqld restart

And then we'll see if it starts up. Two instances:
650) this.width=650; "height=" 118 "src=" http://a3.qpic.cn/psb?/v13tfvpi1vswaw/0pmiod4kue4x*amlyg7zk0a*qfrygyz* wv6kjsrefbi!/b/daobaaaaaaaa&ek=1&kp=1&pt=0&bo=5goiaaaaaaafae4!&su=0124950353&tm= 1492138800&sce=0-12-12&rf=2-9 "width=" 870 "style=" Margin:0px;padding:0px;border-width:0px;border-style: none;vertical-align:top;width:847px;height:114.88px; "Alt=" daobaaaaaaaa&ek=1&kp=1&pt=0&bo= 5gOIAAAAA "/>
OK, we found two instances of two ports have been started


This article is from the "xinsz08の parallel space-time" blog, be sure to keep this source http://xinsz08.blog.51cto.com/10565212/1915903

MySQL Multi-instance run

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.