您的位置:首页 > 数据库 > MySQL

windows下mysql忘记root密码

2017-07-26 15:54 267 查看
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、给该问件加上了只读权限(去掉他的只读权限)
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: