shell/数据库安装.sh

182 lines
4.7 KiB
Bash
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/usr/bin/bash
#by xiaoshun
#位置变量
#function_yum(){
# rm -rf /etc/yum.repos.d/*
# curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo &>/dev/null
# yum -y install wget vim &>/dev/null
# wget -O /etc/yum.repos.d/epel.repo https://mirrors.aliyun.com/repo/epel-7.repo &>/dev/null
#
# }
#
#function_cherrytree(){
# yum -y install cherrytree &>/dev/null
#
#}
#
#
#function_ntfs-3g(){
# yum -y install ntfs-3g-2022.10.3-1.el7.x86_64 &>/dev/null
#
#
#}
#
#cat <<-eof
#
# ~~~◢ ◤◢ ◤
#    ◢ █ █ █ █ ◤ 1)配置yum
#  ⊙█ █ █ █ █ █ █ ◤ 2)安装cherrytree
#● █ █ █ █ █ █ █ █ ◤ 3)安装ntfs-3g
# ▼  ~◥ █ █ █ ◤ *)按q退出
# ▲ ▃ ▃ ◢ █ █ █  ●  ●  ●  ●  ●  ● 
#     █ █ █ /█ /█ /█ /█ /█ /█    ◢ ◤
#     █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ █ ◤
#
#eof
#
#read -p "请输入你的选项[1/2/3]" num
#
#case $num in
#1) function_yum
#;;
#2) function_cherrytree
#;;
#3) function_ntfs-3g
#;;
#*) echo "点错了 退出"
# exit;;
#esac
#function_free(){
#
# free_used=`free -m | awk NR==2'{print $3}'`
# free_total=`free -m | awk NR==2'{print $2}'`
# free_syl=$(((free_used*100)/free_total))
# free_sss=`echo $free_syl | sed 's/%/ /'`
# echo "内存使用率为$free_syl"%
#}
#
#
#function_disk(){
#
# disk_used=`df -m | awk NR==2'{print $3}'`
# disk_used1=`df -m | awk NR==2'{print $5}'| sed 's/%/ /'`
# echo "磁盘剩余容量$disk_used"
# echo "磁盘的使用率为$disk_used1%"
#}
#
#
#function_uptime(){
#
# linux_uptime=`uptime | cut -d, -f3-`
# echo "系统的平均负载是$linux_uptime"
#}
#
#cat <<-eof
# 1)查看cpu使用
# 2)磁盘剩余
# 3)系统负载
# *)退出
#eof
#
#
#
#read -p "请输入要检查的的数据[1/2/3]" num
#
#case $num in
#
#1) function_free
#;;
#2)function_disk
#;;
#3)function_uptime
#;;
#*) exit
#;;
#esac
#安装数据库
function_az(){
yum -y install https://dev.mysql.com/get/mysql80-community-release-el7-11.noarch.rpm &>>/dev/null
yum -y install yum-utils &>>/dev/null
yum-config-manager --disable mysql80-community $>>/dev/null
yum-config-manager --enable mysql57-community $>>/dev/null
yum -y install mysql mysql-server $>>/dev/null
systemctl restart mysqld
echo "数据库已经安装完毕"
}
function_xg(){
mima=`cat /var/log/mysqld.log | grep root@localhost: | awk '{print $NF}'`
mysqladmin -uroot -p"$mima" password 'Qianfeng@123'
echo "密码修改完成"
}
function_cz(){
systemctl stop mysqld
if [ $? -eq 0 ];then
rm -rf /var/lib/mysql/*
rm -rf /var/log/mysqld.log
else
echo "没有关闭服务"
fi
}
function_sc(){
rm -rf /var/log/mysqld.log
yum -y remove mysql* mysql-server
rpm -qa | grep mysql &>/dev/null
if [ $? -eq 0 ];then
echo "mysql已经清理完毕"
else
echo "机器里还有不干净东西呢"
fi
}
cat <<-eof
◢ █ █ █ █ █ █ █ █ █ █ █ █ ◣       
   █ █ █ █ █ █ █ █ █ █ █ █ █ █       
   █ █   ◥ █ █ ◤   █ █       
 ◢ █ █ █    ◥ ◤    █ █ ◣      
 ▊▎█ ◣          ◢ █ ▊▊      
 ▊▎█ █ ◤   ●  ●   ◥ █ ▊ ▊     
 ▊ █ █         █ ▊ ▊      
 ◥ ▇ █ █ ▊      ▊ █ ▇ ◤      
   █ █ ◥ ▆ ▄ ▄ ▄ ▄ ▆ ◤ █ ▊    ◢ ▇ ▇ ◣
◢ █ █ ◥ ◥ ▆ ▅ ▄ ▂ ▂ ▂ ▂ ▄ ▅ ▆ █ █ █ ◣ ▊ █
  a)安装数据库      ╳ █ ◤◢ ◤
◥ █ ◣ b)修改初始密码     ◢ █ ◤  ◢ ◤ 
   c)重置数据库      ▊    █  
   d)卸载数据库      ▊   ◢◤  
  ▊ *)退出       █ ▇ ▇ ▇ ◤  
 ◢ █ ▇ ▆ ▆ ▆ ▅ ▅ ▅ ▅ ▆ ▆ ▆ ▇ █ ◣      
 ▊ ▂ ▊      ▊ 
eof
read -p "请输入对数据库的操作[a/b/c/d]" num
case $num in
a)function_az
;;
b)function_xg
;;
c)function_cz
;;
d)function_sc
;;
*)exit
;;
esac