标签:mysql安装脚本
#!/bin/sh
#install mysql
#check install is not
check_ok () {
if [ $? != "0" ];then echo -e "\033[32m the install is not\033[0m";break
else
echo -e "\033[33m is ok\033[0m"
fi
}
#off the iptables and selinux
iptables -F
service iptables save
check_ok
if [ "getenforce" == "Enforcing" ];then setenforce 0;sed -ir ‘s/SELINUX=enforcing/SELINUX=disabled/g‘ /etc/selinux/config
check_ok
else echo -e "\033[32m the selinux is off\033[3m"
fi
#install mysql
cd /usr/local/src
wget -c http://mirrors.sohu.com/mysql/MySQL-5.1/mysql-5.1.73-linux-x86_64-glibc23.tar.gz
tar xzf mysql-5.1.73-linux-x86_64-glibc23.tar.gz
check_ok
mv mysql-5.1.73-linux-x86_64-glibc23 /usr/local/mysql && cd /usr/local/mysql && /bin/cp support-files/my-large.cnf /etc/my.cnf && /bin/cp support-files/mysql.server /etc/init.d/mysqld
sed -ir ‘s#^basedir=$#basedir=/usr/local/mysql#g‘ /etc/init.d/mysqld
sed -ir ‘s#^datadir=$#datadir=/data/mysql#g‘ /etc/init.d/mysqld
useradd mysql && ./scripts/mysql_install_db --user=mysql --datadir=/data/mysql
check_ok
echo -n "export PATH=$PATH:/usr/local/mysql/bin" /etc/profile.d/path.sh
source /etc/profile.d/path.sh
chkconfig --add mysqld && chkconfig mysqld on
/etc/init.d/mysqld start
check_ok
本文出自 “学习linux” 博客,请务必保留此出处http://10265013.blog.51cto.com/10255013/1764211
标签:mysql安装脚本
原文地址:http://10265013.blog.51cto.com/10255013/1764211