[root@localhost ~]# cat install_mysql-5.6.15\(1\).sh
#!/bin/bash
yum -y remove mysql*
yum -y install gcc gcc-c++ gcc-g77 make libtool autoconf patch unzip automake libxml2 libxml2-devel ncurses ncurses-devel libtool-ltdl-devel libtool-ltdl libmcrypt libmcrypt-devel libpng libpng-devel libjpeg-devel openssl openssl-devel curl curl-devel libxml2 libxml2-devel ncurses ncurses-devel libtool-ltdl-devel libtool-ltdl autoconf automake libaio* traceroute lsof tree telnet dos2unix sysstat lrzsz nc nmap man ntpdate gcc gcc-c++ libgcc openssh-* openssl ntpdate bash
mysql_dir='/alidata/server/mysql'
mkdir -p $mysql_dir
if [ `uname -m` == "x86_64" ];then
machine=x86_64
else
machine=i686
fi
if [ $machine == "x86_64" ];then
rm -rf mysql-5.6.15-linux-glibc2.5-x86_64
if [ ! -f mysql-5.6.15-linux-glibc2.5-x86_64.tar.gz ];then
wget http://oss.aliyuncs.com/aliyunecs/onekey/mysql/mysql-5.6.15-linux-glibc2.5-x86_64.tar.gz
fi
tar -xzvf mysql-5.6.15-linux-glibc2.5-x86_64.tar.gz
mv mysql-5.6.15-linux-glibc2.5-x86_64/* $mysql_dir
else
rm -rf mysql-5.6.15-linux-glibc2.5-i686
if [ ! -f mysql-5.6.15-linux-glibc2.5-i686.tar.gz ];then
wget http://oss.aliyuncs.com/aliyunecs/onekey/mysql/mysql-5.6.15-linux-glibc2.5-i686.tar.gz
fi
tar -xzvf mysql-5.6.15-linux-glibc2.5-i686.tar.gz
mv mysql-5.6.15-linux-glibc2.5-i686/* $mysql_dir
fi
groupadd mysql
useradd -g mysql -s /sbin/nologin mysql
$mysql_dir/scripts/mysql_install_db --datadir=$mysql_dir/data/ --basedir=$mysql_dir --user=mysql
chown -R mysql:mysql $mysql_dir/
chown -R mysql:mysql $mysql_dir/data/
\cp -f $mysql_dir/support-files/mysql.server /etc/init.d/mysqld
sed -i "N;46i\basedir=$mysql_dir" /etc/init.d/mysqld
sed -i "N;46i\datadir=$mysql_dir/data" /etc/init.d/mysqld
cat > /etc/my.cnf <
[client]
port = 3306
socket = /tmp/mysql.sock
[mysqld]
port = 3306
socket = /tmp/mysql.sock
basedir=$mysql_dir
datadir=$mysql_dir/data
skip-external-locking
key_buffer_size = 16M
max_allowed_packet = 1M
table_open_cache = 64
sort_buffer_size = 512K
net_buffer_length = 8K
read_buffer_size = 256K
read_rnd_buffer_size = 512K
myisam_sort_buffer_size = 8M
innodb_buffer_pool_size=150M
log-bin=mysql-bin
expire_logs_days = 7
binlog_format=mixed
server-id = 1
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
[mysqldump]
quick
max_allowed_packet = 16M
[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
[mysql]
no-auto-rehash
[myisamchk]
key_buffer_size = 20M
sort_buffer_size = 20M
read_buffer = 2M
write_buffer = 2M
[mysqlhotcopy]
interactive-timeout
END
ln -s $mysql_dir/bin/mysql /usr/sbin/
ln -s $mysql_dir/bin/mysqladmin /usr/sbin/
ln -s $mysql_dir/bin/mysqldump /usr/sbin/
chmod 755 /etc/init.d/mysqld
/etc/init.d/mysqld start