mysql修改密码BASH脚本

写下常用脚本,利用EOF子命令来执行后续命令,没事练练手

#!/bin/bash
#author merci
echo "Please input old password"
read  o
echo "Please inpput new password"
read  n
echo "Please inpput repassword"
read  r
if [ $n != $r ]; then
        echo "Password Inconsistent !"
        exit 1
fi
mysql -u root -p$o <<EOF
use mysql;
update user set password=password("$n") where user="root";
flush privileges;
exit
EOF

分解符EOF可以定义任何字符串,这个和php的定界符还是有一丢丢相似

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://sulao.cn/post/487.html

我要评论

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。