A MySQL database launches multiple instances

Source: Internet
Author: User

1. Compile and install MySQL5.5

# yum install -y cmake gcc gcc-c++  Make cmake ncurses ncurses-devel# groupadd mysql# useradd -g mysql  -s /sbin/nologin mysql# tar zxvf mysql-5.5.31.tar.gz# cd mysql-5.5.31 # cmake -dcmake_install_prefix=/usr/local/mysql5.5-dsysconfdir=/usr/local/mysql5.5/etc -dmysql_ Datadir=/usr/local/mysql5.5/data# make && make install# cp support-files /my-medium.cnf /usr/local/mysql5.5/etc/my3306.cnf# cp support-files/my-medium.cnf/usr/local/ Mysql5.5/etc/my3307.cnf# chown -r mysql.mysql/usr/local/mysql5.5/# echo ' PATH= $PATH:/usr/ Local/mysql5.5/bin '  >> /etc/profile# source /etc/profile 

# cd /usr/local/mysql5.5/etc/# mkdir&nbsp, .... /data3306     #创建数据库数据目录 # mkdir  /data3307# vi my.cnf[mysqld_multi]mysqld = /usr/local/mysql5.5/bin/mysqld_safemysqladmin  = /usr/local/mysql5.5/bin/mysqladminuser = root        #登陆数据库用户password  = 123        #登陆数据库密码 for shutting down the database with two database password settings [mysqld1 ]user = mysqlport = 3306socket = /tmp/mysql3306.sockpid-file = /usr/ local/mysql5.5/data3306/mysql.pidbasedir = /usr/local/mysql5.5datadir = /usr/local/ mysql5.5/data3306log_error = /var/log/mysql/3306_error.log[mysqld2]user = mysqlport =  3307socket = /tmp/mysql3307.sockpid-file = /usr/local/mysql5.5/data3307/ Mysql.pidbasedir = /usr/local/mysql5.5datadir = /usr/local/mysql5.5/data3307log_error  = /var/log/mysqL/3307_error.log 

# mysqld_multi --defaults-file=/usr/local/mysql5.5/etc/my.cnf  start 1# mysqld_multi --defaults-file=/usr/local/mysql5.5/etc/my.cnf start 2# Start or close 1,2# mysqld_multi --defaults-file=/usr/local/mysql5.5/etc/my.cnf start/stop 1,2# at the same time See if MySQL starts # mysqld_multi --defaults-file=./my.cnf report 1,2reporting mysql  Serversmysql server from group: mysqld1 is runningmysql server from  group: mysqld2 is running# netstat -antp |grep mysqltcp  0     0 0.0.0.0:3306  0.0.0.0:*   LISTEN       20896/mysqld    tcp  0    0  0.0.0.0:3307  0.0.0.0:*   listen      21499/mysqld 

Note: If you do not want to use the Mysqld_multi tool, you can start or close the standalone instance configuration file yourself, as follows:

#/usr/local/mysql5.5/bin/mysqld_safe--DEFAULTS-EXTRA-FILE=/USR/LOCAL/MYSQL5.5/ETC/MY3306.CNF--datadir=/usr/ local/mysql5.5/data3306/--user=mysql Mysqladmin-uroot-p123-s/tmp/mysql3306.sock shutdown

4. Log on Locally

# mysql-s/tmp/mysql3306.sock-p 3307-uroot-p123# mysql-s/tmp/mysql3307.sock-p 3307-uroot-p123

5. Telnet (Remote access permission is enabled first)

Mysql> Grant All on * * to ' root ' @ '% ' identified by ' 123 '; # mysql-h 192.168.1.10-p 3306-uroot-p123# mysql-h 192.168 .1.10-p 3307-uroot-p123

This article is from the "Penguin" blog, please be sure to keep this source http://lizhenliang.blog.51cto.com/7876557/1636016

A MySQL database launches multiple instances

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.