wget https://downloads.mysql.com/archives/get/p/23/file/mysql-community-5.7.29-1.el7.src.rpm
yum install cmake ncurses-devel gcc gcc-c++ vim lsof bzip2 openssl-devel -y
rpm -ivh mysql-community-5.7.29-1.el7.src.rpm
cd /root/rpmbuild/SOURCES
useradd -r -s /sbin/nologin mysql
mkdir -p /data/mysql
chown mysql:mysql /data/mysql
tar xf mysql-5.7.29.tar.gz
tar xf boost_1_59_0.tar.bz2
mv boost_1_59_0 mysql-5.7.29
cd mysql-5.7.29
cmake -DCMAKE_INSTALL_PREFIX=/usr/local/sc_mysql -DMYSQL_DATADIR=/data/mysql -DSYSCONFDIR=/etc -DMYSQL_USER=mysql -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_BOOST=boost_1_59_0
make -j 2
make install
cp /etc/my.cnf /root/mysql.cnf.bak
>/etc/my.cnf
cd /usr/local/sc_mysql/bin
./mysqld --initialize --user=mysql --basedir=/usr/local/sc_mysql/ --datadir=/data/mysql &>/root/temp_password.txt
PATH=$PATH:/usr/local/sc_mysql/bin
echo 'PATH=$PATH:/usr/local/sc_mysql/bin' >>/etc/bashrc
cp ../support-files/mysql.server /etc/init.d/mysqld
service firewalld stop
systemctl disable firewalld
setenforce 0
sed -i 's/=enforcing/=disabled/g' /etc/selinux/config
chkconfig mysqld on
service mysqld start
temp_pwd=$(cat /root/temp_password.txt |tail -1|awk '{print $11}')
mysql -uroot -p$temp_pwd --connect-expired-password -e "set password='Sanchuang123#'"
echo '###### congratulation! your mysql has be installed successfully ######'