#!/bin/bash
# Version: 1.0.0
# Author: go1
# Date: 18/10/30 3:00
# Description: GO1 MYSQL Install Script
#1.判断网络是否通畅无阻
is_use_network=$(ping baidu.com -c 5 | grep -c "min/avg/max")
if [ $is_use_network -ne 1 ]
then
echo 'ERROR! NETWORK BUG'
exit 1
fi
#2.获取当前脚本所在目录
mysql_dir=$(pwd)
#3.菜单选择
echo "
Please Select Install
# ---------------------------------------
1 --- MySQL5.5 ---
2 --- MySQL5.6 ---
3 --- MySQL5.7 ---
4 --- don't install is now ---
# --------------------------------------
"
read -p "Please Input 1,2,3: " Select_Id
if [ $Select_Id -eq 1 ]; then
#停止MySQL服务
#删除MySQL安装目录
#重新安装MySQL5.5
sh $mysql_dir/delete_mysql.sh
echo "MySQL5.5,install...\n"
exit 1
elif [ $Select_Id -eq 2 ]; then
echo "MySQL5.6,install...\n"
sh $mysql_dir/delete_mysql.sh
sh $mysql_dir/mysql56.sh
exit 1
elif [ $Select_Id -eq 3 ]; then
sh $mysql_dir/delete_mysql.sh
echo 'MySQL5.7,install...'
exit 1
else
echo 'no select id, exit...'
exit
fi
update_pwd.sh:
$mysql_dir/bin/mysqladmin -u root password 'sk888'
$mysql_dir/bin/mysql -uroot -psk888 <<EOF
drop database test;
delete from mysql.user where user='';
update mysql.user set password=password('sk888') where user='root';
delete from mysql.user where not (user='root') ;
flush privileges;
exit
EOF
网友评论