原理
http://www.tuicool.com/articles/N7fuea
批量脚本
mysql -uroot -p‘xx‘ -e "select user,host from mysql.user;">/root/user.txt sed -i ‘1d‘ user.txt #sed -i ‘s/[ ][ ]*/@/g‘ user.txt sed -i ‘s/\s\+/@/g‘ user.txt cat alter.sh #!/bin/bash for i in `cat user.txt` do name=`echo $i|awk -F ‘@‘ ‘{print $1}‘` ip=`echo $i|awk -F ‘@‘ ‘{print $2}‘` st="ALTER USER ‘"$name"‘@‘"$ip"‘ PASSWORD EXPIRE NEVER;" echo $st done select user,host,password_last_changed,password_lifetime,password_expired FROM mysql.user WHERE user = ‘xx‘\G flush privileges; cd /root && rm -rf user.txt
时间: 2024-12-15 07:45:15