1 Environment Introduction:
1) Introduction
MySQL version: mysql-5.5.27
cmake:cmake-2.8.8
Operating system: CentOS6.5
Number of MySQL instances: 3
Instance occupancy ports are: 3306, 3307, 3308, respectively
2) This installation of all software resource packages
http://download.csdn.net/detail/clevercode/8662323
2 Configuring the firewall
1) Add 3306,3307,3308 (allow 3306,3307,3308 port through firewall) in firewall configuration file
# Vi/etc/sysconfig/iptables #编辑防火墙配置文件
-A input-m state--state new-m tcp-p TCP--dport 3306-j ACCEPT
-A input-m state--state new-m tcp-p TCP--dport 3307-j ACCEPT
-A input-m state--state new-m tcp-p TCP--dport 3308-j ACCEPT
2) Restart the firewall
#/etc/init.d/iptables Restart #最后重启防火墙使配置生效
3 Installing CMake
Extract
# Cd/usr/local/src/mysql
# tar ZXVF cmake-2.8.8.tar.gz
# CD cmake-2.8.8
Configuration
#./configure
Compile
# make
Installation
# make Install
View version
# cmake-version
4 Installing MySQL
1) Create user
# groupadd MySQL #添加mysql组
# useradd-g MySQL mysql-s/bin/false #创建用户mysql并加入到mysql组, do not allow MySQL users to log in directly to the system
2) Unzip
# Cd/usr/local/src/mysql
# tar ZXVF mysql-5.5.27.tar.gz
# CD mysql-5.5.27
4) configuration
# CMake. -dcmake_install_prefix=/usr/local/mysql
Ps:cmake, the parameters can not be so much, as long as a-dcmake_install_prefix=/usr/local/mysql on the line, we can be configured in MY.CNF. [Mysqld] In the content, see your copy after the my.cnf have these settings, there is no need to set up.
5) Compiling
# make
6) Installation
# make Install
5 Initializing the database
# mkdir-p/data0/dbdata/mysql/3306
# mkdir-p/data0/dbdata/mysql/3307
# mkdir-p/data0/dbdata/mysql/3308
# Chown-r mysql:mysql/data0/dbdata/mysql/3306
# Chown-r mysql:mysql/data0/dbdata/mysql/3307
# Chown-r mysql:mysql/data0/dbdata/mysql/3308
#/usr/local/mysql/scripts/mysql_install_db--basedir=/usr/local/mysql--datadir=/data0/dbdata/mysql/3306--user= Mysql
#/usr/local/mysql/scripts/mysql_install_db--basedir=/usr/local/mysql--datadir=/data0/dbdata/mysql/3307--user= Mysql
#/usr/local/mysql/scripts/mysql_install_db--basedir=/usr/local/mysql--datadir=/data0/dbdata/mysql/3308--user= Mysql
6 Modifying a configuration file
# CP/USR/LOCAL/MYSQL/SUPPORT-FILES/MY-HUGE.CNF/DATA0/DBDATA/MYSQL/3306/MY.CNF
# CP/USR/LOCAL/MYSQL/SUPPORT-FILES/MY-HUGE.CNF/DATA0/DBDATA/MYSQL/3307/MY.CNF
# CP/USR/LOCAL/MYSQL/SUPPORT-FILES/MY-HUGE.CNF/DATA0/DBDATA/MYSQL/3308/MY.CNF
# vi/data0/dbdata/mysql/3308/my.cnf #编辑配置文件 (3306,3307)
Modify the data #在 [client] section
Port = 3308
Socket =/tmp/mysql3308.sock
modifying data #在 [MYSQLD] section
Port = 3308
Socket =/tmp/mysql3308.sock
DataDir =/data0/dbdata/mysql/3308 #添加MySQL数据库路径
: wq! #保存退出
7 Creating an auto-start file
# cp/usr/local/mysql/support-files/mysql.server/etc/rc.d/init.d/mysqld3306
# cp/usr/local/mysql/support-files/mysql.server/etc/rc.d/init.d/mysqld3307
# cp/usr/local/mysql/support-files/mysql.server/etc/rc.d/init.d/mysqld3308
# chmod 755/etc/rc.d/init.d/mysqld3306
# chmod 755/etc/rc.d/init.d/mysqld3307
# chmod 755/etc/rc.d/init.d/mysqld3308
# vi/etc/rc.d/init.d/mysqld3308 #编辑 (3306,3307)
Basedir=/usr/local/mysql #MySQL程序安装路径
datadir=/data0/dbdata/mysql/3308 #MySQl数据库存放目录
Modify
$bindir/mysqld_safe--datadir= "$datadir"--pid-file= "$mysqld _pid_file_path" $other _args >/dev/null 2>&1 &
Become
$bindir/mysqld_safe--defaults-file= "$datadir/my.cnf"--pid-file= "$mysqld _pid_file_path" $other _args >/dev/null 2>&1 &
8 Start the 3306, 3307, 3308 MySQL
# Service mysqld3306 Restart
# Service mysqld3307 Restart
# Service mysqld3308 Restart
9 Check if the port is listening, if 3306,3307,3308, it starts normally
# NETSTAT-ANP | grep 3308
TCP 0 0 0.0.0.0:3308 0.0.0.0:* LISTEN 2348/mysqld
UNIX 2 [ACC] STREAM LISTENING 10780 2348/mysqld/tmp/mysql3308.sock
10 Initialize Password and authorize Telnet (3306,3307)
#/usr/local/mysql/bin/mysqladmin-u root password "pwd3308"-s/tmp/mysql3308.sock
#/usr/local/mysql/bin/mysql-uroot-ppwd3308-s/tmp/mysql3308.sock
Mysql> Grant all privileges on * * to ' root ' @ '% ' identified by ' pwd3308 ' with GRANT option;
mysql> flush Privileges;
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
MySQL multi-instance (multiple configuration file mode)