#!/bin/bash
setenforce 0 #关闭SELinux
/etc/init.d/iptables stop
yum remove boost-* -y && yum remove mysql -y
[ $? -eq 0 ] && mkdir -p /server/mysql
yum install -y cmake make gcc gcc-c++ bison ncurses ncurses-devel
wget https://cdn.mysql.com//Downloads/MySQL-5.7/mysql-boost-5.7.18.tar.gz
tar -xf mysql-boost-5.7.18.tar.gz
cd /root/mysql-5.7.18 ; mv boost/ /server/mysql
userdel -r mysql ; groupadd mysql && useradd -M -s /sbin/nologin -r -g mysql mysql
echo "开始编译安装"
cmake -DCMAKE_INSTALL_PREFIX=/server/mysql -DMYSQL_DATADIR=/server/mysql/data -DSYSCONFDIR=/etc -DMYSQL_UNIX_ADDR=/server/mysql/mysql.sock -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_MEMORY_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DMYSQL_UNIX_ADDR=l -DMYSQL_TCP_PORT=3306 -DENABLED_LOCAL_INFILE=1 -DWITH_PARTITION_STORAGE_ENGINE=1 -DEXTRA_CHARSETS=all -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DDOWNLOAD_BOOST=1 -DWITH_BOOST=/server/mysql/boost
if [ $? -eq 0 ];then
echo "commple ok"
make -j 4 && make install
else
echo "commple fause"
fi
if [ $? -eq 0 ];then
echo "即将进行配置文件"
else
echo " 编译安装失败"
exit
fi
cd ~ ; chown mysql.mysql /server/mysql -R
mv /etc/my.cnf{,.bak}
cat >/etc/my.cnf <<Yang
[mysqld]
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
user = mysql
basedir = /server/mysql
port = 3306
pid-file = /server/mysql/data/mysql.pid
socket = /server/mysql/mysql.sock
character-set-server=utf8
[client]
socket = /server/mysql/mysql.sock
Yang
if [ $? -ne 0 ];then
echo "检查/etc/my.cnf"
fi
cp /server/mysql/support-files/mysql.server /etc/init.d/mysqld
chmod +x /etc/init.d/mysqld
/server/mysql/bin/mysqld --initialize-insecure --user=mysql --basedir=/server/mysql --datadir=/server/mysql/data
[ $? -eq 0 ] && /etc/init.d/mysqld start
[ $? -eq 0 ] && chkconfig mysqld on
ln -s /server/mysql/bin/* /usr/local/bin
[ $? -eq 0 ] && echo "please input mysql check"
echo "安装成功