MySQL密码修改(四)
一、修改破解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密码修改(四)的更多相关文章
- [分享]运维分享一一阿里云linux系统mysql密码修改脚本
[分享]运维分享一一阿里云linux系统mysql密码修改脚本 大象吃豆子 级别: 小白 发帖 12 云币 27 加关注 写私信 只看楼主 更多操作楼主 发表于: 2014-09-3 ...
- centos 安装mysql密码修改后还是不能连接的原因
centos 上安装mysql密码修改后还是不能连接出现错误:ERROR 1142 (42000): SELECT command denied to user ''@'localhost' for ...
- kali linux 2018.2 mysql密码修改后无效,外部无法连接问题。
kali linux 2018.2 mysql密码修改后无效,外部无法连接问题 Kali Linux 2018.2 默认MySQL数据库是mariadb,可能和MySQL有些细微的变化,只需要做如下处 ...
- linux系统mysql密码修改脚本
编写了一个适用于阿里云linux系统 mysql密码修改脚本,使用阿里云提供的一键安装包配置后,如果account.log文件删除,并且忘记mysql密码时,可以通过脚本来重置mysql密码. 附:一 ...
- wamp的mysql密码修改
==方法1== 通过WAMP打开mysql控制台,提示输入密码,因为现在是空,所以直接按回车. 输入“use mysql”,意思是使用mysql这个数据库教程,提示“Database changed” ...
- WAMP 默认mysql密码修改
WAMP安装好后,mysql密码是为空的,那么要如何修改呢?其实很简单,通过几条指令就行了,下面我就一步步来操作. 首先,通过WAMP打开mysql控制台. 提示输入密码,因为现在是空,所以直接按回车 ...
- 修改mysql密码的四种方法
方法1: 用SET PASSWORD命令 首先登录MySQL. 格式:mysql> set password for 用户名@localhost = password('新密码'); 例子:my ...
- centos下mysql密码修改与远程连接
之前的服务器,好久没上去过了,今天上去,密码居然又忘了... 要修改mysql的登陆密码,首先要设置 #vim /etc/my.cnf 在[mysqld] 下面加上一句 skip-grant-tabl ...
- MySQL 密码修改
方法1: 用SET PASSWORD命令 首先登录MySQL. 格式:mysql> set password for 用户名@localhost = password('新密码'); 例子:my ...
随机推荐
- 2018.09.15 bzoj1977:次小生成树 Tree(次小生成树+树剖)
传送门 一道比较综合的好题. 由于是求严格的次小生成树. 我们需要维护一条路径上的最小值和次小值. 其中最小值和次小值不能相同. 由于不喜欢倍增我选择了用树链剖分维护. 代码: #include< ...
- RAC环境数据库重启实例
1.重启之前最好先看一下节点信息和运行状态 可以通过srvctl status database -d 数据库名 //查看节点信息 Crs_stat //查看节点状态 可以看到数据节点它由两个实例组成 ...
- gj8 元类编程
8.1 property动态属性 from datetime import date, datetime class User: def __init__(self, name, birthday): ...
- Caused by: org.hibernate.InvalidMappingException: Could not parse mapping document from resource Caused by: org.hibernate.DuplicateMappingException: duplicate import: Person refers to both cn.itcast.
此错误是说有两个相同的名字的配置文件,所以不知道查找哪个.解决方法就是把不需要的那个配置文件删除. 删除mapping中不需要的那个xml文件即可
- CentOS7+Nginx+多个Tomcat配置
转载自:https://blog.csdn.net/name_chc/article/details/73332272:亲测可用,加了一些注释: 配置多个tomcat转发 另附上tomcat启动慢的解 ...
- 常用的SLAM解决方案
ORB SLAM 可以去Github上自己搜索现成的SLAM程序包 在此基础上做优化 视觉SLAM的分类方法:按摄像头的多少分为单目和双目,按是否使用概率方法分为概率法和图法 链接 学习SLAM重要的 ...
- centos yum command
yum repolist all -- 列出所有仓库 yum list all -- 列出仓库中所有软件包 yum info package-name -- 查看软件包信息 yum install p ...
- The Activities of September
- 成员函数指针与高性能C++委托
1 引子 标准C++中没有真正的面向对象的函数指针.这一点对C++来说是不幸的,因为面向对象的指针(也叫做“闭包(closure)”或“委托(delegate)”)在一些语言中已经证明了它宝贵的价值. ...
- WinRT 中检查 WiFi 是否可用
public static bool IsWifiConnected() { bool isWifiConnected = false; ConnectionProfile currentConnec ...