#!/bin/sh
#install MySQL
#check Install is not
Check_ok () {
If [$? = "0"];then echo-e "\033[32m The Install is not\033[0m";
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
This article is from the "Learn Linux" blog, so be sure to keep this source http://10265013.blog.51cto.com/10255013/1764211
MySQL installation script