一: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. ora-12519:TNS ,no appropriate service handler found

    今天有同事反应,数据库连不了,提示 ora-12519:TNS ,no appropriate service handler found: 一开始以为监听没有启动,排查后,发现正常:于是google ...

  2. 使用TextTest来做认定测试——本质是通过diff对比程序的运行log输出,来看测试结果和预期结果是否相同

    Welcome to TextTest.org! TextTest is an open source tool for text-based functional testing. This mea ...

  3. php数组合并

    php的数合并函数: array_merge($arr1, $arr2, ..., $arr{$n}); 如果数组的键名有重复,后面的会覆盖前面的. 如果键名是数字索引,则会重新排列索引,往后累加. ...

  4. YII好的博客

    http://blog.csdn.net/wzllai/article/details/7659008

  5. 并不对劲的loj3049:p5284:[十二省联考]字符串问题

    题目大意 给出字符串\(S(|S|\leq2\times10^5)\), \(na(na\leq2\times 10^5)\)个区间\([l_i,r_i]\)表示\(S_{l_i},S_{l_i+1} ...

  6. vue.js created函数注意事项

    因为created钩子函数是页面一加载完就会调用的函数,所以如果你想在这个组件拿值或者是赋值,很可能this里面能拿到数据,但是如果你用this.赋值的话,控制台或者debugger都会发现this里 ...

  7. aidl笔记 2/5/2015

    interface Test { //测试的接口 void fun();} Stub 是一个Binderclass Stub extend Binder implements Test { publi ...

  8. <正则吃饺子>:关于集合的简单整理总结

    项目中用到的集合不可谓不多,对于自己的一次面试,要求说下自己用过的集合,自己开始说的并不系统也不完整,一直耿耿于怀,特整理一下,以备后期之用和帮助后来者. package com.love.malin ...

  9. NodeJS REST API with MySQL and Express

    http://www.nodewiz.biz/nodejs-rest-api-with-mysql-and-express/ NPM Modules Express felixge/node-mysq ...

  10. codeforces#536题解

    CodeForces#536 A. Lunar New Year and Cross Counting Description: Lunar New Year is approaching, and ...