Centos7安装 mysql5.6.29 shell脚本
有很多可以借鉴的地方,故转载:
创建脚本mysql.sh,直接运行sh mysql.sh
!/bin/bash
if [ -d /software ] ;then
cd /software
else
mkdir /software && cd /software
fi
is exist command ,if not,yum install
is_exist() {
which $1
if [ $? -ne 0 ] ;then
yum -y install $1
fi
}
dolownad the mysql install package,if exist,check the md5sum,if correct,tar;else rm and download
if [ -f mysql-5.6.29.tar.gz ] ;then
mysql_md5=md5sum mysql-5.6.29.tar.gz | cut -d " " -f 1
mysql_md5_true="aaa21c6450adee3a1894fd1710f02bf5"
if [ "$mysql_md5" = "$mysql_md5_true" ] ;then
tar -zxvf mysql-5.6.29.tar.gz
else
rm -rf mysql-5.6.29.tar.gz
rm -rf mysql-5.6.29
fi
else
is_exist wget
wget http://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.29.tar.gz
tar -zxvf mysql-5.6.29.tar.gz
fi
see the yum source is use
yum cleanup
yum makecache
install the depend package
yum -y install gcc make cmake ncurses-devel libxml2-devel libtool-ltdl-devel gcc-c++ autoconf automake bison zlib-devel
add mysql group and user
is_user_mysql=cat /etc/passwd |awk -F ":" '{print $1}' |grep mysql
is_group_mysql=cat /etc/group |awk -F ":" '{print $1}' |grep mysql
if [ "$is_group_mysql" != "mysql" ] ;then
groupadd mysql
fi
if [ "$is_user_mysql" != "mysql" ] ;then
useradd -r -s /sbin/nologin -g mysql mysql
fi
compile and install
cd mysql-5.6.29
cmake .
make && make install
chown -R mysql.mysql /usr/local/mysql
init database
/usr/local/mysql/scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data
copy the important file to /etc
cp /usr/local/mysql/my.cnf /etc/my.cnf
sed -i 's/# basedir = ...../basedir = /usr/local/mysql/g' /usr/local/mysql/my.cnf
sed -i 's/# port = ...../port = 3306/g' /usr/local/mysql/my.cnf
sed -i 's/# datadir = ...../datadir = /usr/local/mysql/data/g' /usr/local/mysql/my.cnf
sed -i '/[mysqld]/a\log-error=/usr/local/mysql/log/error.log' /usr/local/mysql/my.cnf
sed -i '/[mysqld]/a\log=/usr/local/mysql/log/log' /usr/local/mysql/my.cnf
sed -i '/[mysqld]/a\log-slow-queries=/usr/local/mysql/log/slowquery.log' /usr/local/mysql/my.cnf
sed -i '/[mysqld]/a\long_query_time=2' /usr/local/mysql/my.cnf
sed -i '/[mysqld]/a\pid-file=/usr/local/mysql/data/mysql.pid' /usr/local/mysql/my.cnf
sed -i '/[mysqld]/a\character-set-server=utf8' /usr/local/mysql/my.cnf
echo "[client] " >> /usr/local/mysql/my.cnf
echo "socket = /var/lib/mysql/mysql.sock" >>/usr/local/mysql/my.cnf
/usr/local/mysql/scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data
use database
/usr/local/mysql/bin/mysqld_safe --user=mysql &
cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
chkconfig --add mysqld
chkconfig mysqld on
ln -s /var/lib/mysql/mysql.sock /tmp/mysql.sock
start the service
service mysqld restart
import environment
PATH=$PATH:/usr/local/mysql/bin
echo "export PATH=$PATH:/usr/local/mysql/bin >> /etc/profile"
source /etc/profile
转载:http://www.jb51.net/article/107611.htm
Centos7安装 mysql5.6.29 shell脚本的更多相关文章
- Centos7 安装 MySQL5.7
Centos7 安装 MySQL5.7 一.环境介绍 1.安装包版本介绍 MySQL 有三种安装方式:RPM安装.二进制包安装.源码包安装.我们这篇文章以二进制方式安装MySQL 软件名称 版本 系统 ...
- 全自动安装mongoDB数据库的shell脚本
最近在研究mongoDB数据库,写了个全自动安装mongoDB数据库的shell脚本,仅供参考,欢迎拍砖,内容如下: #!/bin/bash # shell的执行选项: # -n 只读取shell脚本 ...
- centos7安装mysql5.7.19及配置远程连接
centos7安装mysql5.7.19及配置远程连接------https://blog.csdn.net/Lh19931122/article/details/77996213
- CentOS7.5源码编译安装mysql5.7.29
#查看系统版本 [root@ctos3 ~]# cat /etc/redhat-release CentOS Linux release (Core) #下载源码包,需要注意的是mysql5.7 编译 ...
- Centos7安装mysql5.6.29shell脚本
创建脚本mysql.sh,直接运行sh mysql.sh #!/bin/bash if [ -d /software ] ;then cd /software else mkdir /software ...
- Centos7安装Mysql5.7方法总结 - 实操手册
Centos7.x版本下针对Mysql的安装和使用多少跟之前的Centos6之前版本有所不同的,废话就不多赘述了,下面介绍下在centos7.x环境里安装mysql5.7的几种方法:一.yum方式安装 ...
- 一个自动安装LNMP的简洁Shell脚本
此脚本在生产服务器上使用了一年多,本脚本崇尚简单唯美,只需要一个脚本就可以在任何一台有网络的服务器上自动配置LNMP.本脚本会在脚本执行目录下,建packages目录用于存放LNMP所需要的软件.大家 ...
- CentOS7安装MySQL5.7及Tomcat8.5
在CentOS7服务器上部署FR项目应用 一.安装CentOS-7_x86_64 1.CentOS7:带GUI的服务器(FTP服务器.JAVA平台.兼容性程序库.开发工具.安全性工具.系统管理工具): ...
- centos7 安装mysql5.7及配置
一.Mysql 各个版本区别:1.MySQL Community Server 社区版本,开源免费,但不提供官方技术支持.2.MySQL Enterprise Edition 企业版本,需付费,可以试 ...
随机推荐
- GIT的使用方法
GIT的使用方法 1.电脑首先安装GIT, 2.在官网注册GitHub账号. 一,使用git在控制台进行本地操作 1.打开GitBash 2.填写用户名和邮箱作为标识分别执行以下命令: git/ co ...
- Wow! Such Doge! HDU - 4847(虽然是道水题 但很有必要记一下)
就是求出现了多少次doge 不区分大小写 巧用字符串函数 isalpha 判断是否是字母 tolower 转换为小写字母 toupper 转换为大写字母 strncmp字符串比较函数 能限制比较的 ...
- c# base64算法解密
/// <summary> /// 将字符串使用base64算法加密 /// </summary> /// <param name="code_type&quo ...
- MT【145】不变的平面角
(2018,4月学考数学选择最后一题)如图,设矩形$ABCD$所在平面与梯形$ACEF$所在平面相交于$AC$. 若$AB=1,BC=\sqrt{3},AF=EF=EC=1,$则下面二面角的平面角为定 ...
- 【刷题】BZOJ 2301 [HAOI2011]Problem b
Description 对于给出的n个询问,每次求有多少个数对(x,y),满足a≤x≤b,c≤y≤d,且gcd(x,y) = k,gcd(x,y)函数为x和y的最大公约数. Input 第一行一个整数 ...
- 【BZOJ2830/洛谷3830】随机树(动态规划)
[BZOJ2830/洛谷3830]随机树(动态规划) 题面 洛谷 题解 先考虑第一问. 第一问的答案显然就是所有情况下所有点的深度的平均数. 考虑新加入的两个点,一定会删去某个叶子,然后新加入两个深度 ...
- 响应式开发(五)-----Bootstrap CSS----------Bootstrap 网格系统
如果我们看过一些bootstrap的框架,经常看到col-sm-3等样式class. Bootstrap 提供了一套响应式.移动设备优先的流式网格系统,随着屏幕或视口(viewport)尺寸的增加,系 ...
- spark 性能调优(一) 性能调优的本质、spark资源使用原理、调优要点分析
转载:http://www.cnblogs.com/jcchoiling/p/6440709.html 一.大数据性能调优的本质 编程的时候发现一个惊人的规律,软件是不存在的!所有编程高手级别的人无论 ...
- centos详细安装redis步骤
1. 从官网(http://redis.io)下载最新稳定版2. 使用命令解压下载的tar包:tar –zxvf redis-3.2.0.tar.gz3. 通过命令cd redis-3.2.0进入源码 ...
- laravel 实用扩展包
1.beyondcode / laravel-self-diagnosis 环境检测.检测 php 版本.扩展 是否正常,数据库连接是否正常等 2.nunomaduro/larastan larave ...