1. 程式人生 > >Password expiration policy in MySQL Server 5.7

Password expiration policy in MySQL Server 5.7

mysql5.7

原理

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 [email protected] ‘{print $1}‘`
ip=`echo $i|awk -F [email protected]
/* */ ‘{print $2}‘` st="ALTER USER ‘"$name"[email protected]"$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


本文出自 “python 運維” 博客,謝絕轉載!

Password expiration policy in MySQL Server 5.7