1 Star 3 Fork 2

奶瓶OO/shell脚本

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
mysql_install.sh 946 Bytes
一键复制 编辑 原始数据 按行查看 历史
奶瓶OO 提交于 2020-02-09 19:10 . 我的shell代码
#!/bin/bash
rpm_mysql=`rpm -qa|grep mysql|wc -l`
Mysql_init=`ss -lntp|grep 3306|grep -v grep|wc -l`
Mysql_passwd=`grep "temporary password" /var/log/mysqld.log|awk -F "[ :]+" '{print $NF}'`
if [ $rpm_mysql -eq 0 ];then
echo "Mysql is not install..."
[ -d /home/packages ] || mkdir -p /home/packages
cd /home/packages && wget -q http://dev.mysql.com/get/mysql57-community-release-el7-8.noarch.rpm
rpm -ivh /home/packages/mysql57-community-release-el7-8.noarch.rpm
yum clean all && yum makecache
yum install mysql-community-server -y
if [ $Mysql_init -eq 0 ];then
systemctl start mysqld
systemctl status mysqld &>/dev/null
if [ $? -eq 0 ];then
echo "Mysqld is running..."
systemctl enable mysqld
mysqladmin -uroot "-p$Mysql_passwd" password "Xujun66207383!@#$"
exit 0
else
echo "Mysqld is no running"
exit 1
fi
fi
else
echo "Mysql is install..."
exit 0
fi
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Shell
1
https://gitee.com/NaiPingOO/shell_script.git
git@gitee.com:NaiPingOO/shell_script.git
NaiPingOO
shell_script
shell脚本
master

搜索帮助