Centos7安装 mysql5.6.29 shell脚本
作者:Lemon_乐 时间:2024-01-15 22:17:41
本文实例为大家分享了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
标签:Centos7,mysql5.6.29,mysql5.6
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
python数组的复制与列表中的pop
2021-07-10 12:05:24
![](https://img.aspxhome.com/file/2023/4/67944_0s.png)
ASP和Javascript中取整函数的应用
2009-06-07 18:38:00
Python数据结构dict常用操作代码实例
2022-05-13 02:16:43
Python列表list常用内建函数实例小结
2021-08-07 02:17:15
Python OpenCV 调用摄像头并截图保存功能的实现代码
2022-07-08 03:11:13
Sql Server 数据库索引整理语句,自动整理数据库索引
2024-01-14 02:37:25
python 多进程和协程配合使用写入数据
2023-01-31 10:48:25
![](https://img.aspxhome.com/file/2023/8/109388_0s.png)
Python 实现opencv所使用的图片格式与 base64 转换
2021-02-28 11:59:09
简述Python中的进程、线程、协程
2021-04-07 11:19:02
Python取出字典中的值的实现
2022-01-09 20:16:07
内容为空时提交如何处理
2009-07-17 18:25:00
![](https://img.aspxhome.com/file/UploadPic/20097/17/twitter-400x94-35s.gif)
Win10下安装CUDA11.0+CUDNN8.0+tensorflow-gpu2.4.1+pytorch1.7.0+paddlepaddle-gpu2.0.0
2022-05-08 19:29:32
![](https://img.aspxhome.com/file/2023/5/70145_0s.jpg)
收集的几个Python小技巧分享
2023-06-14 01:54:01
一文读懂navicat for mysql基础知识
2024-01-23 00:46:25
![](https://img.aspxhome.com/file/2023/1/112341_0s.png)
Vue.js原理分析之nextTick实现详解
2024-05-13 09:38:08
Oracle9iPL/SQL编程的经验小结
2024-01-17 11:12:01
SQL Report Builder 报表里面的常见问题分析
2024-01-23 19:10:47
选择python进行数据分析的理由和优势
2022-03-31 10:51:01
python框架flask知识总结
2023-07-27 20:24:53
![](https://img.aspxhome.com/file/2023/5/61445_0s.png)
Python使用captcha库制作带参数输入验证码案例
2022-01-25 20:26:03
![](https://img.aspxhome.com/file/2023/2/95792_0s.jpg)