#!/bin/sh##install mysql database#echo -e "/n/n"while echo -en "/nAre you sure install mysql database now (yes/no)?";read qrdo if [ "$qr" = "yes" ]; then break elif [ "$qr" = "no" ]; then exit 1 fidonewhile echo -en "/nPlease input install file(tar.gz):";read ifiledo if [ ! -e "$ifile" ] ; then echo " Not found install file !" continue else break fi donewhile echo -en "/nPlease input install to path:";read ipathdo while echo -en "/ninstall to:$ipath (yes/no)?";read qr do if [ "$qr" = "yes" ] ; then break 2 elif [ "$qr" = "no" ] ; then break 1 fi donedonemkdir -p $ipathtar -zxvf $ifile -C $ipath > installmysql.logmysqldir=$ipath"/"`ls ${ifile}|awk -F .tar.gz '{ print $1}'`#link directoryif [ -h "/usr/local/mysql" ] ; then rm -f /usr/local/mysqlfiln -s $mysqldir /usr/local/mysql#file name#add contentetcfile=/etc/my.cnftouch $etcfileecho "[mysqld]">$etcfileecho " datadir=/usr/local/mysql/data">>$etcfileecho " port=3307">>$etcfileecho " socket=/tmp/mysql.sock">>$etcfileecho "[mysql.server]">>$etcfileecho " user=mysql">>$etcfileecho " basedir=/usr/local/mysql">>$etcfileecho "[safe_mysqld]">>$etcfileecho " err-log=/usr/local/mysql/log/mysqld.log">>$etcfileecho " pid-file=/tmp/mysqld.pid">>$etcfile#addusergroupadd mysqluseradd -g mysql mysql#if [ -h /bin/mysql ] ; then rm -f /bin/mysqlfiln -s /usr/local/mysql/bin/mysql /bin/mysql#echo "/usr/local/mysql/bin/mysqld_safe &">>/etc/rc.local#initial mysqldbcp /usr/local/mysql/share/fill_help_tables.sql /usr/local/mysql/support-files/fill_help_tables.sqlcp /usr/local/mysql/share/mysql_fix_privilege_tables.sql /usr/local/mysql/support-files/mysql_fix_privilege_tables.sqlchgrp -R mysql $mysqldirchown -R mysql $mysqldirchmod -R 700 $mysqldir cd /usr/local/mysql/./scripts/mysql_install_db --user=mysql >installmysql.log#Run mysqld/usr/local/mysql/bin/mysqld_safe &sleep 10/usr/local/mysql/bin/mysqladmin create mydb#------------------------------------------------------------------------------------------------------------t1="CREATE TABLE MESSAGE_STATS (id_stats tinyint(3) unsigned NOT NULL,description varchar(100) default NULL,PRIMARY KEY (id_stats)) ENGINE=InnoDB DEFAULT CHARSET=latin1;"/usr/local/mysql/bin/mysql --database=mydb --execute="$t1"echo -e "/n/n LineHandlerGW mysql database install success!/n/n"