时间:2021-07-01 10:21:17 帮助过:28人阅读
脚本内容如下:
#!/bin/bash ######################################## #auth:wolf_dreams #time:2018-10-20 #bbs:https://www.cnblogs.com/Wolf-Dreams/ ######################################## Softwarename="mysql-5.6.40-linux-glibc2.12-x86_64" Binarypacket="/services/tools/${Softwarename}.tar.gz" Basedir="/application" if [ -f $Binarypacket ];then mkdir $Basedir; cd / && tar zxvf $Binarypacket -C $Basedir else exit 1 fi if [ $? -eq 0 ];then /bin/mv $Basedir/$Softwarename $Basedir/mysql-5.6.40 else exit 1 fi grep mysql /etc/passwd if [ $? -ne 0 ];then useradd -s /sbin/nologin -M mysql else exit 1 fi if [ -d $Basedir/mysql-5.6.40/ ];then ln -s $Basedir/mysql-5.6.40/ $Basedir/mysql chown -R mysql:mysql $Basedir/mysql else exit 1 fi $Basedir/mysql/scripts/mysql_install_db --user=mysql --basedir=$Basedir/mysql --datadir=$Basedir/mysql/data /bin/cp -p $Basedir/mysql/support-files/my-default.cnf /etc/my.cnf echo "explicit_defaults_for_timestamp=true" >> /etc/my.cnf /bin/cp -p $Basedir/mysql/support-files/mysql.server /etc/init.d/mysqld sed -i "s#/usr/local/mysql#$Basedir/mysql#g" $Basedir/mysql/bin/mysqld_safe /etc/init.d/mysqld if [ $? -eq 0 ];then /etc/init.d/mysqld start chkconfig --list | grep mysqld if [ $? -ne 0 ];then chkconfig --add mysqld chkconfig mysqld on fi else exit 1 fi echo "export PATH=$PATH:$Basedir/mysql/bin" >> /etc/profile source /etc/profile > /dev/null 2>&1 exit 0
Mysql_Binary_Install_Scripts(采用二进制方式安装)
标签:add profile my.cnf bin usr $path _for tar zxvf file