一、修改破解MySQL密码

  1.1:修改密码

在知道原始密码的情况下
[root@web1 ~]# mysqladmin -uroot -p -S /home/mysql/3307/mysql.sock password "brian123" # 要修改的密码
Enter password:123456 # 测试
[root@web1 ~]# mysql -uroot -p -S /home/mysql/3307/mysql.sock
Enter password:123456
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES) [root@web1 ~]# mysql -uroot -p -S /home/mysql/3307/mysql.sock
Enter password:brian123
[root@web1 ~]# mysql -uroot -p -S /home/mysql/3307/mysql.sock
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 6
Server version: 5.7.23 MySQL Community Server (GPL) Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> # 登录数据库修改密码
update mysql.user set authentication_string=password('123qwe') where user='root' and Host = 'localhost';
alter user 'root'@'localhost' identified by '123';
set password for 'root'@'localhost'=password('123');
# 一定记得刷新权限,不然不生效
flush privileges;

  1.2:破解密码

# 数据库密码忘记了
PS:在单实例的情况下我们是可以停掉数据库的,但是在多实例的情况下没有密码是停不了的,只能用kill 来停的 # 使用kill停止不记得密码的数据库
[root@web1 ~]# ps aux | grep 3306 | awk '{print $2}' |xargs kill # 使用mysqld_safe 加参数绕过认证
PS: 我用的是多实例的,根据实际情况修改下面的路径就行
[root@web1 ~]# /usr/local/mysql/bin/mysqld_safe --defaults-file=/home/mysql/3306/my.cnf --user=mysql --skip-grant-tables &
[root@web1 ~]# netstat -lntup | grep 3306
tcp6 0 0 :::3306 :::* LISTEN 57475/mysqld # 现在就是没有密码可以登录了
[root@web1 ~]# mysql -uroot -p -S /home/mysql/3306/mysql.sock
Enter password: # 这一步直接回车
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.23 MySQL Community Server (GPL) Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> # 进来以后再修改密码
mysql> update mysql.user set authentication_string=password('123qwe') where user='root' and Host = 'localhost';
Query OK, 1 row affected, 1 warning (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 1 mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec) mysql> # 停掉MySQL重新启动 这次不用指定--skip-grant-tables参数了
[root@web1 ~]# ps aux | grep 3306 | awk '{print $2}' |xargs kill
[root@web1 ~]# /usr/local/mysql/bin/mysqld_safe --defaults-file=/home/mysql/3306/my.cnf --user=mysql &
[root@web1 ~]# mysql -uroot -p -S /home/mysql/3306/mysql.sock
Enter password: 123qwe
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.23 MySQL Community Server (GPL) Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql>

  

MySQL密码修改(四)的更多相关文章

  1. [分享]运维分享一一阿里云linux系统mysql密码修改脚本

    [分享]运维分享一一阿里云linux系统mysql密码修改脚本       大象吃豆子 级别: 小白 发帖 12 云币 27 加关注 写私信   只看楼主 更多操作楼主  发表于: 2014-09-3 ...

  2. centos 安装mysql密码修改后还是不能连接的原因

    centos 上安装mysql密码修改后还是不能连接出现错误:ERROR 1142 (42000): SELECT command denied to user ''@'localhost' for ...

  3. kali linux 2018.2 mysql密码修改后无效,外部无法连接问题。

    kali linux 2018.2 mysql密码修改后无效,外部无法连接问题 Kali Linux 2018.2 默认MySQL数据库是mariadb,可能和MySQL有些细微的变化,只需要做如下处 ...

  4. linux系统mysql密码修改脚本

    编写了一个适用于阿里云linux系统 mysql密码修改脚本,使用阿里云提供的一键安装包配置后,如果account.log文件删除,并且忘记mysql密码时,可以通过脚本来重置mysql密码. 附:一 ...

  5. wamp的mysql密码修改

    ==方法1== 通过WAMP打开mysql控制台,提示输入密码,因为现在是空,所以直接按回车. 输入“use mysql”,意思是使用mysql这个数据库教程,提示“Database changed” ...

  6. WAMP 默认mysql密码修改

    WAMP安装好后,mysql密码是为空的,那么要如何修改呢?其实很简单,通过几条指令就行了,下面我就一步步来操作. 首先,通过WAMP打开mysql控制台. 提示输入密码,因为现在是空,所以直接按回车 ...

  7. 修改mysql密码的四种方法

    方法1: 用SET PASSWORD命令 首先登录MySQL. 格式:mysql> set password for 用户名@localhost = password('新密码'); 例子:my ...

  8. centos下mysql密码修改与远程连接

    之前的服务器,好久没上去过了,今天上去,密码居然又忘了... 要修改mysql的登陆密码,首先要设置 #vim /etc/my.cnf 在[mysqld] 下面加上一句 skip-grant-tabl ...

  9. MySQL 密码修改

    方法1: 用SET PASSWORD命令 首先登录MySQL. 格式:mysql> set password for 用户名@localhost = password('新密码'); 例子:my ...

随机推荐

  1. Docker挂载宿主机目录

    一.普通方式直接挂载 1.查看已有容器 docker ps 2.进入容器并挂载 docker run -it -v /root/work/docker:/root/hzbtest tomcat:7.0 ...

  2. yum基本操作(转)

    原文地址:http://www.cnblogs.com/chuncn/archive/2010/10/17/1853915.html yum(全称为 Yellow dog Updater, Modif ...

  3. 学习前端的菜鸡对JS的call,apply,bind的通俗易懂理解

       call,apply,bind 在JavaScript中,call.apply和bind是Function对象自带的三个方法,都是为了改变函数体内部 this 的指向.            a ...

  4. 20155211 2016-2017-2 《Java程序设计》第七周学习总结

    20155211 2016-2017-2 <Java程序设计>第七周学习总结 教材学习内容总结 第十二章 Lambda Lambda表达式中this的参考对象以及toString()的接受 ...

  5. day3之文件操作

    一,文件操作基本流程. # 1.打开文件,产生文件句柄 # 2.操作文件句柄 # 3.关闭文件句柄 # f1 = open('11.txt',encoding='utf-8', mode='r') # ...

  6. MySQL的NO_BACKSLASH_ESCAPES

    官方说明: https://dev.mysql.com/doc/refman/5.7/en/mysql-real-escape-string.html 相关资料: https://dev.mysql. ...

  7. C语言中交换两个数值的方法

    //方法1    int  one = 1;    int two = 2;    int temp = 0;    temp = one;    one = two;    two = temp;  ...

  8. C++和Python混合编程

    为何人工智能(AI)首选Python?读完这篇文章你就知道了:https://blog.csdn.net/qq_41769259/article/details/79419322 C++调用Pytho ...

  9. MFC 的SetWindowPos 用法

    转自于:http://hi.baidu.com/max_new/blog/item/e2bbe607b1f127c57b8947c0.html 许多软件,特别是占桌面面积不是很大的软件,通常都提供了一 ...

  10. Apache Geode with Spark

    在一些特定场景,例如streamingRDD需要和历史数据进行join从而获得一些profile信息,此时形成较小的新数据RDD和很大的历史RDD的join. Spark中直接join实际上效率不高: ...