一:readme:

 、此脚本仅仅适合于5.7免面编译安装版本。
、安装是需自己选择mysql软件安装包:例如mysql-5.7.-linux-glibc2.-x86_64.tar.gz或者mysql-5.7.-linux-glibc2.-x86_64.tar.gz;请选择glibc版及免编译版本。
、此脚本可选择自动下载和手动上传安装软件包进行安装。
选择自动下载安装请提前获取下载地址并根据提示输入下载URL;如选择手动上传需提前下载好软件包并确认系统中有lrzsz包。
.安装过程中需要手动输入安装路径以及mysql数据存储路径,请提前规划好。也可根据提示输入路径。。
5安装完成后请注意提示,因为脚本会输出此次安装后的登录密码,请记住登录密码。可使用/etc/init.d/mysqld start|stop|restart进行启停。启动后请使用所给的登录密码登录(每次安装登录密码随机)。

二:脚本代码:

 #!/bin/sh
##########################################
# this script is created by xuxuedong. #
# e_mail:***@qq.com #
# qqinfo:*** #
# This is install Mysql5. #
# version:1.1 #
##########################################
. /etc/init.d/functions
#set env
export PATH=$PATH:/bin:/sbin:/usr/sbin
export LANG="zh_CN.GB18030"
packge=/home/admin/tools # Require root to run this script. 判断是否是root用户执行。
#if [[ "$(whoami)" != "root" ]]; then
# echo "Please run this script as root." >&
# exit
#fi
#Show users how to install.让用户选择如何安装
menu ( ){ cat<<END
.手动上传安装
.网络下载安装
.[exit]
pls input the num that you want:
END }
menu
read num
echo "you choice $num"
#upload the packge by user 用户自己上传安装文件
function upload(){
if [ -e $packge ]
then
cd ${packge}&rz
else
mkdir -p ${packge}&cd ${packge}&rz
fi
if [ $? -eq ]
then
action "THE sofeware is upload to ${packge}" /bin/true
else
action "THE sofeware is upload fail" /bin/false
fi
}
###############################
#donwload the packge from URL 用户自己输入下载路径
function WGET(){
while True
do
if [ -e $packge ]
then
cd ${packge}
read -p "input donwload URL:" URL
if [$URL != z ]
then
wget $URL
if [ $? -eq ]
then
action "THE sofeware is download to ${packge}" /bin/true
break
else
Continue
fi
else
mkdir -p ${packge}&cd ${packge}
fi
fi
done
if [ $? -eq ]
then
action "THE sofeware is upload to ${packge}" /bin/true
else
action "THE sofeware is upload fail" /bin/false
fi
}
########################
##install Mysql 自动安装 可用while循环实现只有输入目录才能执行
function InsTall(){
read -p "input a installdir for install mysql(example /application/newmysql):" installdir
if [ -e $installdir ]
then
action "THE dir is exist" /bin/true
else
mkdir -p $installdir
fi
# Installdir = $installdir
read -p "input a mysqldata_dir for mysql_data(example /application/newmysql/3306data):" mysqldata_dir
if [ -e $mysqldata_dir ]
then
action "THE dir is exist" /bin/true
else
mkdir -p $mysqldata_dir
fi
# Mysqldata_dir = $mysqldata_dir
cd ${packge}
echo "`ls -l mysql*`"
read -p "please input you want to install version:" ver
tar -zxf $ver -C $installdir
cd $installdir
echo "`ls -l `"
read -p "please input you want to install version:" installroot_dir
rm -rf ${mysqldata_dir}/*
${installroot_dir}/bin/mysqld --initialize --basedir=${installdir} --datadir=${mysqldata_dir}
if [ $? -eq 0 ]
then
action "mysql is install initialize" /bin/true
else
action "mysql is install initialize false" /bin/false
exit
fi
ln -s ${installroot_dir}/bin $installdir/bin
cp ${installroot_dir}/support-files/mysql.server /etc/init.d/mysqld
cp ${installroot_dir}/support-files/my-default.cnf /etc/my.cnf
cat >>/etc/my.cnf <<EOF
[client]
port=3306
user=iddbs
password ='newpassword'
socket=${mysqldata_dir}/mysql.sock
[mysqld]
max_connections=1000
max_user_connections=500
wait_timeout=200
user=iddbs
server-id=5
port=3306
basedir=$installdir
datadir=${mysqldata_dir}
socket=${mysqldata_dir}/mysql.sock
pid-file=${mysqldata_dir}/mysql.pid
log-bin=${mysqldata_dir}/mysql-bin
relay-log=${mysqldata_dir}/relay-bin
log-error=${mysqldata_dir}/mysql-error.log
interactive_timeout=172800
wait_timeout=172800
max_allowed_packet=16M
expire_logs_days=7
auto-increment-increment=2
auto-increment-offset=1
character-set-server=utf8
collation_server=utf8_general_ci
innodb_data_file_path=ibdata1:1G:autoextend
innodb-buffer-pool-size=15G
binlog_format=row
relay_log_recovery=1
log_bin_trust_function_creators=1
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
lower_case_table_names = 1
character_set_server = utf8
event_scheduler = on
[mysqldump]
quick
max_allowed_packet = 16M [mysql]
no-auto-rehash
# Remove the next comment character if you are not familiar with SQL
#safe-updates
default-character-set = utf8 [myisamchk]
key_buffer_size = 512M
sort_buffer_size = 512M
read_buffer = 8M
write_buffer = 8M
EOF echo "export PATH=$PATH:${installdir}/bin">>/etc/profile
source /etc/profile
echo "mysql login password for root is:`cat ${mysqldata_dir}/mysql-error.log | grep password`"
}
function quit(){
if [ "$num" -eq 3 ]
then
echo "logout..."
exit 0
fi
} case $num in
1)
upload
InsTall
;;
2)
WGET
InsTall
;;
3)
quit
;; *)
echo "USAG:1|2|3"
esac

三:完成登录数据库后操作:

  由于mysql5.7基于安全考虑对于通过第一次安装密码进行登录后,无法进行操作的问题(不能查看库、表等):

  请点击此处

Mysql5.7免编译版自动安装脚本的更多相关文章

  1. mysql 自动备份和nginx自动安装脚本

    一.自动备份Mysql脚本: 如下脚本为mysql自动备份脚本,仅供参考,可以根据实际情况修改. #!/bin/sh #auto backup mysql #wugk #Define PATH定义变量 ...

  2. Windows ftp脚本和RSCD agent自动安装脚本

    Windows ftp脚本 和bladelogic RSCD Agent自动安装脚本 比较简单的命令是msiexec /I "C:\RSCD85-SP1-WIN64.msi" /Q ...

  3. python第三方库自动安装脚本

    #python第三方库自动安装脚本,需要在cmd中运行此脚本#BatchInstall.pyimport oslibs = {"numpy","matplotlib&qu ...

  4. LAMP自动安装脚本

    #!/bin/bash # 功能描述:LAMP自动安装脚本 # 初始化 if [ "$(cat /etc/system-release | awk '{print $(NF-1)}' | a ...

  5. python3自动安装脚本,python3.x与python2.x共存

    1.前言: python3过程中,通过搜索一些文章参考安装过程发现比较麻烦,而且还出现一些不可预期的报错.python3环境需要升级openssl,所以为了部署到其他环境更方便,写自动安装脚本方式,且 ...

  6. 自动安装脚本-------------基于LVMP搭建Nagios 监控

    Mysql初始化参数(mysql-5.6.31) /usr/local/mysql/scripts/mysql_install_db --user=mysql --basedir=/usr/local ...

  7. OpenJDK自动安装脚本 InstallOpenJDK.vbs

    Oracle JDK 要收费了,Open JDK没有安装包,只有Zip,写了个安装脚本 InstallOpenJDK.vbs Rem ********************************* ...

  8. hadoop自动安装脚本

    还不能实现完全自动安装,只能算半自动的. 进行交互主要障碍有两点: 1. ssh-keygen的时候需要点击回车. 2. passwd 需要设置密码  如果谁能解决以上两点,欢迎email给我. 另外 ...

  9. mysql5.6源码自动安装脚本

    将脚本与源码安装包放在同一目录下,执行脚本即可(执行脚本会使用yum安装依赖包) 安装完成之后,既可以使用mysql -uroot -p登录   脚本内容如下: [root@mysql src]# c ...

随机推荐

  1. zkui部署

    1.拉取代码 #git clone https://github.com/DeemOpen/zkui.git 2.构建并安装程序 #cd zkui/ #yum install -y maven #mv ...

  2. ffmpeg 中av_rescale_rnd 的含义

    http://blog.csdn.net/fireroll/article/details/8485482 一.函数声明: int64_t av_rescale_rnd(int64_t a, int6 ...

  3. hdu Integer Inquiry 解题报告

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1047 题目意思:就是求大整数加法.有多个案例,每个案例之间要输出一个空格. #include < ...

  4. Java丨时间判断谁前谁后

    直奔主题: String date_str1 = "2016-06-02 23:03:123"; String date_str2 = "2016-06-03 03:03 ...

  5. H3C-端口镜像

    本地端口镜像配置举例 配置Switch: <Sysname> system-view [Sysname] mirroring-group 1 local # 创建本地镜像组 [Sysnam ...

  6. Watir RAutomation VS AutoIt to deal with popup

    Watir使用过程中,经常遇到的弹出框分为几类: 1. Alert 2. Confirm 3. Prompt 4. File select Watir 处理弹出框,有很多方法,可以应用 AutoIt来 ...

  7. AtCoder Grand Contest 012 D:Colorful Balls

    题目传送门:https://agc012.contest.atcoder.jp/tasks/agc012_d 题目翻译 给你一排一共\(N\)个球,每个球有一个颜色\(c_i\)和一个重量\(w_i\ ...

  8. bzoj 2655 calc —— 拉格朗日插值

    题目:https://www.lydsy.com/JudgeOnline/problem.php?id=2655 先设 f[i][j] 表示长度为 i 的序列,范围是 1~j 的答案: 则 f[i][ ...

  9. codevs-2235

    2235 机票打折 题目描述 Description .输入机票原价(3到4位的正整数,单位:元),再输入机票打折率(小数点后最多一位数字).编程计算打折后机票的实际价格(单位:元.计算结果要将个位数 ...

  10. 红帽系统制作yum本地源

    1 首先得吐槽吐槽,机房冷就算了,不能用手机(哈哈你懂的),没有站的位置,显示屏看不清楚.就这样开始制作yum本地源. 2 记下注意得两点,以防以后会忘记 a:可能是因为红帽系统,加上是实用光盘挂载的 ...