需求
现在有这么一个需求, 需要大批量修改用户的密码, 需要注意的规则是:
必须添加的字符: *$#sjdKw%
用户名的第一位+*$#sjdKw%+用户名的最后一位,比如用户名chenglee,密码:c*$#sjdKw%e
下面开始吧, 我sql不好, 没法实现, 只能写shell了.
#!/bin/bash
user="root"
pass="lizhenghua"
ip="192.168.137.174"
function My(){
#ifirst
mysql --protocol=TCP -u ${user} -p''${pass}'' -h ${ip} --connect-expired-password -e "select LEFT(id, 1) from chengleedb.chenglee_user" > first.txt
#last
mysql --protocol=TCP -u ${user} -p''${pass}'' -h ${ip} --connect-expired-password -e "select SUBSTRING(id, -1) from chengleedb.chenglee_user" > last.txt
#export
#mysql --protocol=TCP -u ${user} -p''${pass}'' -h ${ip} --connect-expired-password -e "SELECT (@i:=@i+1) i,id