centos7 自动化脚本编译安装mysql-boost-5.7.31
不需要自己找包,脚本里面自己下载了,执行一下脚本直接解放双手,脚本还直接该密码,如果你喜欢可以进入脚本里面自己去更改,在脚本的最下面,我已经写好备注,有什么不好的欢迎提出。
警告一下:不要在真实环境使用,出了事情概不负责,谢谢!!!
话不多说,直接上脚本
所有的路径都在/usr/local/mysql
mysql安装目录:/usr/local/mysql
mysql数据目录:/usr/local/mysql/data
mysql采用默认端口:port 3306
#!/bin/bash
#此脚本编译安装mysql5.7.31
#邮箱:[email protected]
echo "清理环境"
systemctl stop mysqld mariadb &>/dev/null
yum erase -y `rpm -qa |grep mariadb` 2>/dev/null
yum erase -y `rpm -qa |grep mysql` 2>/dev/null
rm -rvf /etc/my.cnf /var/lib/mysql
userdel -rf mysql &>/dev/null
ping -w3 -c3 www.baidu.com
if [[ $? -ne 0 ]];then
echo "网络不通畅,请检查网络通畅性"
exit
else
echo "网络通畅,正在进行wget软件下载"
fi
while :
do
yum -y install ncurses ncurses-devel openssl-devel bison gcc gcc-c++ make cmake wget && wget -P /usr/local/src/ -nc https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-boost-5.7.31.tar.gz
if [[ $? -eq 0 ]];then
break
else
yum -y install ncurses ncurses-devel openssl-devel bison gcc gcc-c++ make cmake wget && wget -P /usr/local/src/ -nc https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-boost-5.7.31.tar.gz
fi
done
tar -zxvf /usr/local/src/mysql-boost-5.7.31.tar.gz -C /usr/local/src/
cd /usr/local/src/mysql-5.7.31
cmake . \
-DWITH_BOOST=boost/boost_1_59_0/ \
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DSYSCONFDIR=/etc \
-DMYSQL_DATADIR=/usr/local/mysql/data \
-DINSTALL_MANDIR=/usr/share/man \
-DMYSQL_TCP_PORT=3306 \
-DMYSQL_UNIX_ADDR=/tmp/mysql.sock \
-DDEFAULT_CHARSET=utf8 \
-DEXTRA_CHARSETS=all \
-DDEFAULT_COLLATION=utf8_general_ci \
-DWITH_READLINE=1 \
-DWITH_SSL=system \
-DWITH_EMBEDDED_SERVER=1 \
-DENABLED_LOCAL_INFILE=1 \
-DWITH_INNOBASE_STORAGE_ENGINE=1
groupadd mysql
echo "
[mysqld]
basedir=/usr/local/mysql
datadir=/usr/local/mysql/data
">/etc/my.cnf
make && make install
if [[ $? -eq 0 ]];then
useradd -r -g mysql -s /bin/nolgin mysql
cd /usr/local/mysql
mkdir /usr/local/mysql/mysql-files
chown -R mysql.mysql /usr/local/mysql
/usr/local/mysql/bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data &>/root/mysql
else
echo "make && make install失败"
exit
fi
if [[ $? -eq 0 ]];then
echo "export PATH=$PATH:/usr/local/mysql/bin" >> /etc/profile
source /etc/profile
cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
chkconfig mysqld on
echo "可以使用systemctl管理mysql"
else
exit
fi
systemctl start mysql
mysql_passwd=`cat /root/mysql |awk 'NR==7''{print $11}'`
/usr/local/mysql/bin/mysqladmin -u root -p${mysql_passwd} password LiuLiuBin@123 #<-------此处更换密码
if [[ $? -eq 0 ]];then
echo “密码已经修改完成,密码为LiuLiuBin@123” #<----此处也得改
else
exit
fi