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
不过这中间也可能有别的错误,如:
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文件时,将该文件损坏(将该文件修复一下)