#!/bin/bash
groupadd mysql
useradd -g mysql -s /sbin/nologin mysql
mkdir -p /data/3306
chown -R mysql.mysql /data/3306
chmod 755 /data/3306
#mount -o loop /tmp/rhel6.iso /mnt/
yum -y install make gcc-c++ cmake bison-devel ncurses-devel openssl openssl-devel bison
tar -zxvf /tmp/mysql-5.6.16.tar.gz -C /usr/local/src/
mv /usr/local/src/mysql-5.6.16/ /usr/local/src/mysql-master
read -n1 var
cd /usr/local/src/mysql-master
cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql-master/ \
-DMYSQL_DATADIR=/data/3306/data \
-DMYSQL_TCP_PORT=3306 \
-DMYSQL_UNIX_ADDR=/var/run/mysqld/mysql-master.sock \
-DSYSCONFDIR=/usr/local/mysql-master \
-DDEFAULT_CHARSET=gbk \
-DDEFAULT_COLLATION=gbk_chinese_ci \
-DWITH_EXTRA_CHARSETS=ALL \
-DMYSQL_USER=mysql
read -n1 var
make
read -n1 var
make install
read -n1 var
chown -R mysql.mysql /usr/local/mysql-master
/usr/local/mysql-master/scripts/mysql_install_db --basedir=/usr/local/mysql-master --datadir=/data/3306/data --user=mysql
cp /usr/local/mysql-master/support-files/mysql.server /etc/init.d/mysqld-master
read -n1 var
chmod +x /etc/init.d/mysqld-master
chkconfig --add mysqld-master
chkconfig mysqld-master on
/etc/init.d/mysqld-master start