当前位置:网站首页>MySQL forgets root password cracking root password cracking all user passwords, shell script
MySQL forgets root password cracking root password cracking all user passwords, shell script
2022-06-24 06:03:00 【eisc】
#!/bin/bash
# mysql Crack reset root password
read -p "
Hello, welcome to continuous integration eisc.cn mysql Crack both remote and localhost Database password
Please enter a user name :" setuser
read -p " Please customize your password :" setpasswd
mycnf="/etc/my.cnf"
NR=`cat -n $mycnf | grep "\[mysqld\]" | awk -F" " '{print $1}'` ; echo $NR
# find [mysqld] The line of the tag
sed -i "/skip-grant-tables/d" $mycnf
# Delete this root Password free login configuration , To add
sed -i "$NR a skip-grant-tables" $mycnf ; systemctl restart mysqld mariadb
# stay mysqld Add password free login configuration information under the label
# Restart the database
echo " The information you entered is :$setuser $setpasswd"
mysqlversion=$(mysql -uroot -peisc.cn -e "select version();" | awk -F"." 'NR==2{print $1}') ; echo "mysql edition :$mysqlversion";
if [ $mysqlversion -gt 7 ];then
echo " The current database version is greater than 7"
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';"
else
mysql -e "use mysql;select user,authentication_string from user; set global read_only=0;set global read_only=1; use mysql;select user,authentication_string from user; set global read_only=0;set global read_only=1; UPDATE user SET password=password('$setpasswd') WHERE user='$setuser';"
echo " lower than 7 Version cracking of "
fi
# Log in to the database to modify root The password for :eisc.cn
# a key :set global read_only=0;set global read_only=1; flush privileges;set global validate_password.policy=0 ; set global validate_password.length=6;
# Turn off the read-only property of the new master library , Read write properties , The length of the password is 6
sed -i "/skip-grant-tables/d" $mycnf; systemctl restart mysqld mariadb
# Delete the previous configuration , Restart the data
# wget eisc.cn/file/shell/mysql-passwd.sh ; sh mysql-passwd.sh边栏推荐
- Some common IPv6 problems!
- Load balancing on Tencent cloud
- Micro build low code supports Excel to import data source
- How to build a website with a domain name? What steps need to be taken?
- Solution to the 39th weekly game of acwing
- Tencent cloud harbor private warehouse deployment practice
- Go concurrency - work pool mode
- Technology is a double-edged sword, which needs to be well kept
- Spirit information development log (4)
- 5 minutes, online from 0 to 1!
猜你喜欢
随机推荐
How to register a domain name? What are the benefits of building a website?
Micro build low code supports Excel to import data source
What does it mean that the domain name is being walled? How to solve the problem of domain name by wall?
As a sigmastar agent, Qiming cloud shares dry goods for you: what are the characteristics of ssd201/202
12. Tencent cloud IOT device side learning -- NTP function and Implementation
How to do reverse domain name resolution? What does reverse domain name resolution mean?
Inferior administrator and black heart Haikang
Test development knowledge map
Tencent (host security) was listed in the market guide for cloud workload protection platform released by Gartner
New core and new speed - next generation standard O & M engine
Risc-v instruction set explanation (7) instruction address alignment and addition and subtraction overflow processing
What is the difference between a white box test and a black box test
Sub process call - process arrangement in complex O & M scenarios
System of test development - create test virtual machine on demand
Koa middleware implementation
How to check the school domain name? Are all school domain names unified?
How to buy a domain name? How to do a good job in website construction?
How about the VIP domain name? Does the VIP domain name need to be filed after registration?
How do websites apply for domain names? How to select a website domain name?
How to build a website with a domain name? What are the precautions for website construction?



