24 Star 47 Fork 23

Hailiang / lnmp

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
reset_mysql_pwd.sh 1.05 KB
一键复制 编辑 原始数据 按行查看 历史
Hailiang 提交于 2018-08-07 09:39 . change blog url
#!/bin/bash
. include/common.sh
clear
echo -e "$GREEN
#####################################################################
# LNMP is a bash script for the installation of Nginx + PHP + MySQL.#
# Author Hehl <1181554113@qq.com> 20170907 #
# Blog Http://www.cnblogs.com/ddif #
# Auto reset password of mysql server #
#####################################################################"
echo -e "$WHITE"
add_skip(){
if [ -f /etc/my.cnf ];then
sed -i 's/\[mysqld\]/\[mysqld\]\nskip-grant-tables/g' /etc/my.cnf
else
echo -e "${RED}NO my.cnf in /etc/"
fi
}
del_skip(){
sed -i 's/skip-grant-tables//g' /etc/my.cnf
}
reset_mysql_pwd(){
read -p "Please input New Mysql root password:" mysql_pwd
add_skip
service mysqld restart
$mysql_cmd -uroot -e "use mysql;UPDATE user SET password=PASSWORD('$mysql_pwd') WHERE user='root' AND host='127.0.0.1' OR host='%' OR host='localhost'"
del_skip
service mysqld restart
echo -e "New Mysql server root password is\033[41m $mysql_pwd\033[0m"
}
reset_mysql_pwd
Shell
1
https://gitee.com/hehl/lnmp.git
git@gitee.com:hehl/lnmp.git
hehl
lnmp
lnmp
master

搜索帮助