首页 > 代码库 > Centos 6.4上面用Shell脚本一键安装mysql 5.6.15
Centos 6.4上面用Shell脚本一键安装mysql 5.6.15
Centos 6.4上面用Shell脚本一键安装mysql 5.6.15
#!/bin/bashif [ `uname -m` == "x86_64" ];thenmachine=x86_64elsemachine=i686fimysqlBasedir=/storage/server/mysqlmysqlDatadir=${mysqlBasedir}/data/mysqlLogdir=/storage/log/mysqlmysqlUser=mysqlmysqlGroup=mysqlmkdir -p $mysqlBasedirmkdir -p $mysqlDatadirmkdir -p $mysqlLogdir#如果mysql已安装,删除原有mysqlif [ $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/* $mysqlBasedirelse 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/* $mysqlBasedirfi#添加mysql用户组groupadd $mysqlGroup#添加mysql用户 ,并制定组为mysql /sbin/nologin意思是用户不允许登录useradd -g $mysqlGroup -s /sbin/nologin $mysqlUser#安装服务${mysqlBasedir}/scripts/mysql_install_db --datadir=$mysqlDatadir --basedir=$mysqlBasedir --user=$mysqlUser #设置权限chown -R ${mysqlUser}:${mysqlGroup} $mysqlBasedirchown -R ${mysqlUser}:${mysqlGroup} $mysqlDatadirchown -R ${mysqlUser}:${mysqlGroup} $mysqlLogdir#把mysql.server放到/etc/init.d 目录下方便使用\cp -f ${mysqlBasedir}/support-files/mysql.server /etc/init.d/mysqld#脚本里面的这两行在mysql启动文件指定mysql数据库的安装目录和数据目录存放目录sed -i ‘s#^basedir=$#basedir=‘${mysqlBasedir}‘#‘ /etc/init.d/mysqldsed -i ‘s#^datadir=$#datadir=‘${mysqlDatadir}‘#‘ /etc/init.d/mysqld#配置文件cat > /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 = 64sort_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
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。