码迷,mamicode.com
首页 > 数据库 > 详细

MySQL服务安装之二:二进制方式一键安装脚本

时间:2016-01-27 13:10:53      阅读:224      评论:0      收藏:0      [点我收藏+]

标签:mysql   shell   二进制安装   


#!/bin/bash
#User        :bobo365
#Date        :20160127

USER=`whoami`
if [ "$USER" != ‘root‘ ] ;then
       echo "Please use root user,Thanks"
       exit
fi

MYSQL_USER=`egrep -i mysql /etc/passwd`
if [ -z "$MYSQL_USER" ] ;then
               useradd -r -s /sbin/nologin mysql
       else
               echo "user mysql was added"
fi

yum install -y vim screen lsof gzip unzip tree ntp curl wget libaio*

wget -O /usr/local/src/mysql-5.6.26-linux-glibc2.5-x86_64.tar.gz http://ftp.ntu.edu.tw/MySQL/Downloads/MySQL-5.6/mysql-5.6.26-linux-glibc2.5-x86_64.tar.gz

cd /usr/local/src
tar -zvxf mysql-5.6.26-linux-glibc2.5-x86_64.tar.gz
mv mysql-5.6.26-linux-glibc2.5-x86_64 /usr/local/mysql

cd /usr/local/
chown -R mysql.mysql mysql/
cd mysql/support-files/
cp mysql.server /etc/init.d/mysql
chkconfig --add mysql
chkconfig --level 35 mysql on
cd ../data/..
scripts/mysql_install_db --user=mysql &

mv /etc/my.cnf /etc/my.cnf_bak
cp /usr/local/mysql/support-files/my-default.cnf /etc/my.cnf
sed -i ‘s/^# basedir = ...../basedir = \/usr\/local\/mysql/g‘ /etc/my.cnf
sed -i ‘s/^# datadir = ...../datadir = \/usr\/local\/mysql\/data/‘ /etc/my.cnf
sed -i ‘s/^# port = ...../port = 3306/‘ /etc/my.cnf
sed -i ‘s/^# socket = ...../socket = \/tmp\/mysql.sock/‘ /etc/my.cnf

chmod 755 /etc/init.d/mysqld
/etc/init.d/mysql start
echo "PATH=$PATH:/usr/local/mysql/bin" >> /etc/profile
source /etc/profile

PROC=`ps aux|grep mysql |grep -v grep -c`
PORT=`netstat -lnp|grep 3306`
if [ ! -z "$PORT" ] && [ "$PROC" -ne 0 ]  ;then
       echo "mysql install and started secussefull"
fi

#mysql -S /tmp/mysql.sock


本文出自 “bobo365的运维之路” 博客,请务必保留此出处http://bobo365.blog.51cto.com/1035992/1738876

MySQL服务安装之二:二进制方式一键安装脚本

标签:mysql   shell   二进制安装   

原文地址:http://bobo365.blog.51cto.com/1035992/1738876

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!