Evo. G Tech Team Forum
Welcome to Evo. G Tech Team Forum. We have moved to a new website : www.evogtechteam.com

Thanks you.

by Evo. G Tech Team Management.

Join the forum, it's quick and easy

Evo. G Tech Team Forum
Welcome to Evo. G Tech Team Forum. We have moved to a new website : www.evogtechteam.com

Thanks you.

by Evo. G Tech Team Management.
Evo. G Tech Team Forum
Would you like to react to this message? Create an account in a few clicks or log in to continue.

【转载】MySQL忘记密码恢复密码的实现方法

Go down

【转载】MySQL忘记密码恢复密码的实现方法 Empty 【转载】MySQL忘记密码恢复密码的实现方法

Post by C Xue Yi June 21st 2015, 18:04

流传较广的方法,mysql中文参考手册上的,各位vps主机租用客户和服务器托管用户忘记mysql5.1管理员密码时,可以使用这种方法破解下
一、服务器环境
1、系统windows2003 中文企业版 sp2
2、mysql 5.1.55
3、php 5.2.17
4、IIS 6.0
二、破解过程
1、停止mysql服务(以管理员身份,在cmd命令行下运行)使用如下命令:

net stop mysql


[You must be registered and logged in to see this image.]

2、.使用命令启动mysql数据库,命令如下


mysqld --skip-grant-tables 或者 mysqld-nt --skip-grant-tables


[You must be registered and logged in to see this image.]

3.新开一个cmd窗口,进行如下命令操作


1、mysql -uroot
2、update mysql.user set password=password('root') where user='你的密码';


如图:
[You must be registered and logged in to see this image.]
4、打开任务管理器,停止mysql,mysqld进程,使用net start mysql启动mysqld服务,就可以使用root用户 root密码进入数据库了(这步可以省略重启机器)
[You must be registered and logged in to see this image.]
mysql5.1管理员密码破解到此结束。
1. 向mysqld server 发送kill命令关掉mysqld server(不是 kill -9),存放进程ID的文件通常在MYSQL的数据库所在的目录中。  
killall -TERM mysqld  
你必须是UNIX的root用户或者是你所运行的SERVER上的同等用户,才能执行这个操作。  
2. 使用`--skip-grant-tables' 参数来启动 mysqld。 (LINUX下/usr/bin/safe_mysqld --skip-grant-tables , windows下c:\mysql\bin\mysqld --skip-grant-tables)  

3. 然后无密码登录到mysqld server ,  
>use mysql  
>update user set password=password("new_pass") where user="root";  
>flush privileges;  
。你也可以这样做:`mysqladmin -h hostname -u user password 'new password''。  

4. 载入权限表: `mysqladmin -h hostname flush-privileges' ,或者使用 SQL 命令`FLUSH PRIVILEGES'。  
5.killall -TERM mysqld  
6.用新密码登陆  

修正一下:我在Windows下的实际操作如下  
1.关闭正在运行的MySQL。  
2.打开DOS窗口,转到mysql\bin目录。  
3.输入mysqld-nt --skip-grant-tables回车。如果没有出现提示信息,那就对了。  
4.再开一个DOS窗口(因为刚才那个DOS窗口已经不能动了),转到mysql\bin目录。  
5.输入mysql回车,如果成功,将出现MySQL提示符 >  
6. 连接权限数据库>use mysql; (>是本来就有的提示符,别忘了最后的分号)  
6.改密码:> update user set password=password("123456") where user="root"; (别忘了最后的分号)  
7.刷新权限(必须的步骤)>flush privileges;  
8.退出 > \q  
9.注销系统,再进入,开MySQL,使用用户名root和刚才设置的新密码123456登陆。  

据说可以用直接修改user表文件的方法:  
关闭MySQL,Windows下打开Mysql\data\mysql,有三个文件user.frm,user.MYD,user.MYI找个知道密码的MySQL,替换相应的这三个文件,如果user表结构没改过,一般也没人去改,替换user.MYD就可以了。  
也可以直接编辑user.MYD,找个十六进制编辑器,UltraEdit就有这个功能。关闭MySQL,打开user.MYD。将用户名root后面的八个字符改为565491d704013245,新密码就是123456。或者将它们对应的十六进制数字,(左边那里,一个字符对应两个数字),改为 00 02 02 02 02 02 02 02,这就是空密码,在编辑器右边看到的都是星号*,看起来很象小数点。重开MySQL,输入root和你的新密码。 
今天有点事要进mssql,因为是很久以前装的,所以忘记了sa的密码,虽然用windows身份验证就可以进,但是如果用php连接mssql时就不行了,于是google了一下,找到了解决方法. 

用windows身份验证机制进去,然后 
输入下列命令,执行: 
exec sp_password null,'newpass','sa' 

示例 
A.无原密码的情况下更改登录密码 
下面的示例将登录 Victoria 的密码更改为 123 
EXEC sp_password NULL,'123','sa' 

B.更改密码 
下面的示例将登录 Victoria 的密码由 123 改为 456 
EXEC sp_password '123','456' 

另外我发现了一个问题,那就是windows和SQL Server身份验证机制有些不同 
windows身份验证 

服务器地址 登陆结果 
127.0.0.1 ok 
localhost wrong 
. ok 

SQL Server身份验证 

服务器地址 登陆结果 
127.0.0.1 ok 
localhost wrong 
. wrong 


另外记录一下忘记mysql 密码的取回方法 
如果 MySQL 正在运行, 
首先杀之: killall -TERM mysqld(如果是windows,直接调出进程管理器,结束之) 
以安全模式启动 MySQ: 
/usr/bin/safe_mysqld --skip-grant-tables & 
(windows 下 mysql安装所以盘/mysql/bin/safe_mysqld --skip-grant-tables ) 
就可以不需要密码就进入 MySQL 了. 
然后就是 
>use mysql 
>update user set password=password("new_pass") where user="root"; 
>flush privileges; 
重新杀 MySQL,用正常方法启动 MySQL.

C Xue Yi
Beginner
Beginner

Posts : 28
Points : 66544
Reputation : 0
Join date : 2015-03-25
Age : 26

Back to top Go down

Back to top


 
Permissions in this forum:
You cannot reply to topics in this forum