一、修改破解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. 661. Image Smoother

    static int wing=[]() { std::ios::sync_with_stdio(false); cin.tie(NULL); ; }(); class Solution { publ ...

  2. 2018.07.31 POJ1741Tree(点分治)

    传送门 只是来贴一个点分治的板子(年轻时候写的丑别介意). 代码: #include<cstdio> #include<cstring> #include<algorit ...

  3. hdu-2844(完全背包+二进制优化模板)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2844 思路:问1-m能的得到的硬币的值,所以dp[i]==i即可. #include<iostr ...

  4. 38 Cell-phone Emissions can change Brain Activity 手机辐射有可能改变大脑活动

    Cell-phone Emissions can change Brain Activity 手机辐射有可能改变大脑活动 So many people use the cell phone so fr ...

  5. [GO]删除切片的某个值

    func removePro(ddbenv []*model.EnvInfo, k int) []*model.EnvInfo { :]...) } for k, v := range ddbenv ...

  6. [转]关于docker包存储结构说明

    原文:http://blog.csdn.net/w412692660/article/details/49005631 前段时间与同事交流docker的安装包层次结构,并沟通相关每个文件的作用,但是一 ...

  7. Java中BufferedReader和scanner

    Scanner 和BufferedReader同样能实现将键盘输入的数据送入程序, import java.io.*;import java.util.Scanner;public class C { ...

  8. Hive 1.2.1&Spark&Sqoop安装指南

    目录 目录 1 1. 前言 1 2. 约定 2 3. 服务端口 2 4. 安装MySQL 2 4.1. 安装MySQL 2 4.2. 创建Hive元数据库 4 5. 安装步骤 5 5.1. 下载Hiv ...

  9. hdu 2149

    题目 巴什博奕(Bash Game) 巴什博奕(Bash Game):只有一堆n个物品,两个人轮流从这堆物品中取物,规 定每次至少取一个,最多取m个.最后取光者得胜. 显然,如果n=m+1,那么由于一 ...

  10. MDX示例:求解中位数、四分位数(median、quartile)

    一个人力资源咨询集团通过网络爬虫采集手段将多个知名招聘网站上发布的求职和招聘等信息准实时采集到自己的库里,形成一个数据量浩大的招聘信息库,跟踪全国招聘和求职的行业.工种.职位.待遇等信息,并通过商业智 ...