---
title: "windows下MySql密码重置"
author: "chamcon"
date: "2014-08-14T16:59:21Z"
tags: []
categories: ["数据库"]
slug: "windows-mysql"
draft: false
lastmod: "2014-08-20T15:52:41Z"
id: 2104006
url: "https://chamcon.iteye.com/blog/2104006"
---

windows下MySql密码重置

 

Windows下操作  www.2cto.com  

1.关闭正在运行的MySQL。 

 

2.打开DOS窗口，转到mysql\\bin目录。 

 

3.输入mysqld --skip-grant-tables回车。

 

如果没有出现提示信息，那就对了。 

 

4.再开一个DOS窗口，转到mysql\\bin目录。 

 

5.输入mysql回车，如果成功，将出现MySQL提示符 &gt; 

 

6\. 连接权限[数据库](http://www.2cto.com/database/)&gt;use [mysql](http://www.2cto.com/database/MySQL/); 

 

6.改密码：&gt; update user set password=password("520") where user="root"; 

 

7.刷新权限&gt;flush privileges; 

 

8.退出 &gt; \\q 

9.注销[系统](http://www.2cto.com/os/)，再进入。

 

flush privileges

GRANT ALL PRIVILEGES ON \*.* TO IDENTIFIED by 'root' WITH GRANT OPTION

 

今天接手一台mysql，root@localhost账户进入，发现授权时报错如下：

ERROR 1044 (42000): Access denied for user 'root'@'localhost' to database 'yao'

最终发现该root在初始授权时没有加上with grant option

 

解决办法：

配置文件中增加skip-grant-tables

重启mysql后重新登录授权报错：

ERROR 1290 (HY000): The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement

这个错误执行flush privileges后再次授权就可以了。