install mysql database

來源:互聯網
上載者:User
#!/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"

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.