当前位置:主页 > 查看内容

mysql 忘记root密码破解root密码破解所有用户密码,shell脚本

发布时间:2021-07-28 00:00| 位朋友查看

简介:read -p "Hello, welcome to continuous integration eisc.cn mysql 同时破解远程和localhost数据库密码请输入用户名:" setuserread -p "请自定义密码:" setpasswdmycnf="/etc/my.cnf"NR=`cat -n $mycnf | grep "\[mysqld" | awk -F" " '{print $1}'` ; ech……
read -p " Hello, welcome to continuous integration eisc.cn mysql 同时破解远程和localhost数据库密码 请输入用户名:" setuser read -p "请自定义密码:" setpasswd mycnf="/etc/my.cnf" NR=`cat -n $mycnf | grep "\[mysqld" | awk -F" " '{print $1}'` ; echo $NR # 找到 [mysqld] 标签所在行 sed -i "/skip-grant-tables/d" $mycnf # 删除这个root免密登录配置,重新添加 sed -i "$NR a skip-grant-tables" $mycnf ; systemctl restart mysqld # 在mysqld 标签下面增加免密登录配置信息 # 重启数据库 echo "您输入的信息为:$setuser $setpasswd" mysql -e "use mysql;select user,authentication_string from user; set global read_only=0;set global read_only=1; set global validate_password.policy=0 ; set global validate_password.length=6;flush privileges;alter user '$setuser'@'localhost' identified by '$setpasswd';alter user '$setuser'@'%' identified by '$setpasswd';" # 登录数据库修改root密码为:eisc.cn # 重点:set global read_only=0;set global read_only=1; flush privileges;set global validate_password.policy=0 ; set global validate_password.length=6; # 关掉新主库的只读属性,读写属性,密码长度为6 sed -i "/skip-grant-tables/d" $mycnf; systemctl restart mysqld # 删除之前的配置,重启数据
本文转自网络,原文链接:https://developer.aliyun.com/article/785798
本站部分内容转载于网络,版权归原作者所有,转载之目的在于传播更多优秀技术内容,如有侵权请联系QQ/微信:153890879删除,谢谢!

推荐图文


随机推荐