Install MySQL database

Source: Internet
Author: 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"

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.