阿里云代理商阿里云服務(wù)器mysql 忘記root密碼破解root密碼破解所有用戶密碼,shell腳本
#!/bin/bash
# mysql 破解重置root密碼
read -p "
Hello, welcome to continuous integration 4526.cn mysql 同時(shí)破解遠(yuǎn)程和localhost數(shù)據(jù)庫(kù)密碼
請(qǐng)輸入用戶名:" setuser
read -p "請(qǐng)自定義密碼:" setpasswd
mycnf="/etc/my.cnf"
NR=`cat -n $mycnf | grep "\[mysqld" | awk -F" " '{print $1}'` ; echo $NR
# 找到 [mysqld] 標(biāo)簽所在行
sed -i "/skip-grant-tables/d" $mycnf
# 刪除這個(gè)root免密登錄配置,重新添加
sed -i "$NR a skip-grant-tables" $mycnf ; systemctl restart mysqld
# 在mysqld 標(biāo)簽下面增加免密登錄配置信息
# 重啟數(shù)據(jù)庫(kù)
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';"
# 登錄數(shù)據(jù)庫(kù)修改root密碼為:4526.cn
# 重點(diǎn):set global read_only=0;set global read_only=1; flush privileges;set global validate_password.policy=0 ; set global validate_password.length=6;
# 關(guān)掉新主庫(kù)的只讀屬性,讀寫(xiě)屬性,密碼長(zhǎng)度為6
sed -i "/skip-grant-tables/d" $mycnf; systemctl restart mysqld
# 刪除之前的配置,重啟數(shù)據(jù)
聚搜云
上海聚搜信息技術(shù)有限公司
阿里云代理商網(wǎng)站:http://m.gzjcsc123.com/
阿里云代理商云店:https://partner.aliyun.com/shop/1690271921397837
阿里云優(yōu)惠券鏈接:http://aliyun.jusoucn.com/
Q/V :582059487 TEL:150-2661-2550
