Centos 6.4 install MySQL 5.6.15 with shell script one click
#!/bin/Bashif[ `uname-M ' = ="x86_64"]; Then Machine=x86_64Else Machine=i686fiMysqlbasedir=/storage/server/Mysqlmysqldatadir=${mysqlbasedir}/data/Mysqllogdir=/storage/log/Mysqlmysqluser=Mysqlmysqlgroup=MySQLmkdir-P $mysqlBasedirmkdir-P $mysqlDatadirmkdir-P $mysqlLogdir # If MySQL is installed, delete the original MySQLif[$machine = ="x86_64"]; Then RM-RF mysql-5.6. the-LINUX-GLIBC2.5-x86_64if[!-F mysql-5.6. the-LINUX-GLIBC2.5-x86_64.Tar. GZ]; Then wgethttp//oss.aliyuncs.com/aliyunecs/onekey/mysql/mysql-5.6.15-linux-glibc2.5-x86_64.tar.gz fi Tar-XZVF mysql-5.6. the-LINUX-GLIBC2.5-x86_64.Tar. GZMVmysql-5.6. the-LINUX-GLIBC2.5-x86_64/*$mysqlBasedirElse RM-RF mysql-5.6. the-LINUX-GLIBC2.5-i686if[!-F mysql-5.6. the-LINUX-GLIBC2.5-i686.Tar. GZ]; Then wgethttp//oss.aliyuncs.com/aliyunecs/onekey/mysql/mysql-5.6.15-linux-glibc2.5-i686.tar.gz fi Tar-XZVF mysql-5.6. the-LINUX-GLIBC2.5-i686.Tar. GZMVmysql-5.6. the-LINUX-GLIBC2.5-i686/*$mysqlBasedirfi#添加mysql用户组groupadd $mysqlGroup # Add MySQL users and set up a group for MySQL/sbin/Nologin means the user is not allowed to log in Useradd-G $mysqlGroup-S/sbin/nologin $mysqlUser # Installation Service ${mysqlbasedir}/scripts/mysql_install_db--datadir= $mysqlDatadir--basedir= $mysqlBasedir--user=$mysqlUser #设置权限Chown-R ${mysqluser}:${mysqlgroup} $mysqlBasedirChown-R ${mysqluser}:${mysqlgroup} $mysqlDatadirChown-R ${mysqluser}:${mysqlgroup} $mysqlLogdir # put Mysql.server in/etc/easy to use in the INIT.D directory \CP-F ${mysqlbasedir}/support-files/mysql.server/etc/init.d/The two lines in the mysqld# script specify the installation directory and data directory of the MySQL database in the MySQL startup filesed-I.'s#^basedir=$ #basedir ='${mysqlbasedir}'#'/etc/init.d/mysqldsed-I.'s#^datadir=$ #datadir ='${mysqldatadir}'#'/etc/init.d/mysqld# configuration fileCat>/etc/my.cnf <<End[client]port=3306Socket=/tmp/Mysql.sock[mysqld]port=3306Socket=/tmp/Mysql.sockskip-external-lockingkey_buffer_size=16mmax_allowed_packet=1mtable_open_cache= -sort_buffer_size=512knet_buffer_length=8kread_buffer_size=256kread_rnd_buffer_size=512kmyisam_sort_buffer_size=8Mlog-bin=mysql-Binbinlog_format=Mixedserver-ID=1Sql_mode=No_engine_substitution,strict_trans_tables[mysqldump]quickmax_allowed_packet=16m[mysql]no-auto-rehash[myisamchk]key_buffer_size=20msort_buffer_size=20mread_buffer=2mwrite_buffer=2m[mysqlhotcopy]interactive-Timeoutendchmod 755/etc/init.d/mysqld/etc/init.d/mysqld start