日期:2014-05-16  浏览次数:20659 次

windows下mysql忘记root密码解决方法

1、首先将mysqld服务停掉

2、在命令行中,cd 到mysql的bin目录下,然后执行如下命令

  mysqld  --skip-grant-tables

此时命令行会停止不动,然后你另起一个命令行

3、在新的命令行中输入:mysql

就可以进入mysql了,然后在在mysql的命令行中输入修改root密码的命令;如下

>use mysql

>update user set password=password("new_pass") where user="root";

>flush privileges;

>exit

4、然后在重启mysql服务就可以了

 

不过这中间也可能有别的错误,如:

InnoDB: Operating system error number 5 in a file operation. InnoDB: The error means mysqld does not have the access rights to InnoDB: the directory. It may also be you have created a subdirectory InnoDB: of the same name as a data file. InnoDB: File name .\ibdata1 InnoDB: File operation call: ‘open’. InnoDB: Cannot continue operation.

  可能的原因是1、在移动那个\ibdata1文件时,将该文件损坏(将该文件修复一下)

                          2、给该问件加上了只读权限(去掉他的只读权限)