首页 > 数据库 >mysql破解root密码

mysql破解root密码

时间:2022-11-23 13:25:53浏览次数:32  
标签:cursor 密码 user mysql root 破解 con

#设置免密登录
echo skip-grant-tables >> /etc/my.cnf
systemctl restart mysqld

#设置密码为空
mysql -e'use mysql;update user set authentication_string="" where user="root";' --connect-expired-password
mysql -e'use mysql;select authentication_string from user where user="root";'  ###验证###

#设置密码登录(但此时实际密码为空)
sed -i 's/^skip-grant-tables//' /etc/my.cnf systemctl restart mysqld #修改密码 mysql -e'alter user root@localhost identified by "Admin@123!";' --connect-expired-password #密码为空时,需要--connect-expired-password才能使用-e在命令行交互。 #echo sql_mode=$(mysql -uroot -pAdmin@123! -e'select @@sql_mode;' | tail -1 | sed 's/ONLY_FULL_GROUP_BY,//') >> /etc/my.cnf #设置only full group by,视自己需求 systemctl restart mysqld

#mysql -uroot -pAdmin@123! -e'show databases'#测试登录
#附:python改密码示例

import pymysql os
#设置免密 os.system(echo "skip-grant-tables" /etc/my.cnf') os.system('service mysqld restart')
#连接mysql,设置密码为空 con = pymysql.connect(host='localhost',user='root',database='mysql') cursor.execute('update user set authentication_string="" where user="root"') con.commit() con.close()
#启用密码登录 os.system('sed -i "s/^skip-grant-tables//" /etc/my.cnf') os.system('service mysqld restart') #修改密码 con = pymysql.connect(host='localhost',user='root',database='mysql') cursor = con.cursor() cursor.execute('alter user root@localhost identified by "Admin@123!"') con.commit() con.close() #密码验证,输出为mysql版本 #con = pymysql.connect(host='localhost',user='root',password='Admin@123!',database='mysql',port=3306)
#cursor = con.cursor()
#data = cursor.fetchone()
#print ("Database version : %s " % data)
#con.close()


 



 

标签:cursor,密码,user,mysql,root,破解,con
From: https://www.cnblogs.com/santia-god/p/16917943.html

相关文章

  • mipsel-linux-gcc 安装,opt/buildroot-gcc342/bin/mipsel-linux-gcc解决办法
    1.Commandnotfound错误的确认用mipsel-Linux-uclibc-gcc编译Uboot时,出现Commandnotfound错误,但是我检查了编译工具的路径等是正确的,之后在编译工具目录直接运行mips......
  • 安装mysql服务添加到systemctl服务当中
    1、https://www.cnblogs.com/dahuo/p/16014689.html把mysqld添加至systemctl进行管理 #复制过去后,会sytemctl会自动识别的 cp/usr/local/mysql/support-f......
  • mysql 报错 1292 - Truncated incorrect DECIMAL value
    数据库维护之时,报错1292sql如下update表1leftjoin表2on表1.关联字段=表2.关联字段set表1.更新字段=表2.字段where表2.字段!=''and表2.字段!='#VALU......
  • MySQL UTF-8 编码下使中文排序生效的办法
    1.查询的时候是加入转换函数SELECT`hotel_name`FROM`hotel_base`ORDERBYconvert(`hotel_name`USINGgbk)COLLATEgbk_chinese_ci 2.设置单个需要中文排序字段的......
  • MySQL数据库初体验
    一.数据库的基本概念1、数据(Data)•描述事物的符号记录•包括数字,文字,图形,图像,声音,档案记录等•以“记录”形式按统一的格式进行存储2、表•将不同的记录组织在......
  • mysql初始化设置密码遇到的问题
    关于这个问题是在mysql初始化时,使用临时密码,修改自定义密码时,由于自定义密码比较简单,就出现了不符合密码策略的问题。解决办法:1.进入mysql输入命令:mysql-root-p2、查......
  • MySQL的概念、编译安装,以及自动补全
    一.数据库的基本概念1、数据(Data)•描述事物的符号记录•包括数字,文字,图形,图像,声音,档案记录等•以“记录”形式按统一的格式进行存储2、表•将不同的记录组织在一......
  • mysqlexecdelete_sql
    #!/bin/bash#auther:don2022/09/30#version01mysql_bin="mysql6603"mysql_user="root"mysql_password="xxxxxx"mysql_sock_path="/home/mysql_6603/mysql.sock"#sql_quer......
  • mysql 5.6 inner join查询慢的优化方案
    SELECT DISTINCTBus_CompleteList.WXOpenId,Bus_UserList.WXNickNameFROM Bus_CompleteListinnerjoinBus_UserListonBus_UserList.WXOpenId=Bus_CompleteList.WXOpen......
  • Mysql数据库部分管理命令极简学习总结
    背景今天遇到一个得很奇怪的问题.Mysql一个运行时间很长的select阻塞了对select里面左连接表做createindex操作的SQL当时感觉不应该,一直以为读锁不会与独占更新锁......