Home > Database > Mysql Tutorial > body text

windows下mysql忘记root密码的解决办法_MySQL

WBOY
Release: 2016-06-01 13:17:45
Original
982 people have browsed it

今天早上 一朋友说自己的mysql 忘记root密码了 让我帮忙给看看,因为没有接触过mysql 所以从网上找了一下信息
经我亲身实践 已经成功!mysql版本是5.1
以下是从网上找的信息:

1、 首先检查mysql服务是否启动,若已启动则先将其停止服务,可在开始菜单的运行,使用命令:

net stop mysql

打开第一个cmd1窗口,切换到mysql的bin目录,运行命令:

mysqld --defaults-file="C:/Program Files/MySQL/MySQL Server 5.1/my.ini" --console --skip-grant-tables

注释:

该命令通过跳过权限安全检查,开启mysql服务,这样连接mysql时,可以不用输入用户密码。 此时已经开启了mysql服务了!

这个窗口保留 不关闭。

2、打开第二个cmd2窗口,连接mysql:

输入命令:

mysql -u root -p

出现:

Enter password:

在这里直接回车,不用输入密码。

然后就就会出现登录成功的信息,

使用命令:

show databases;

使用命令切换到mysql数据库:

use mysql;

使用命令更改root密码:

UPDATE user SET Password=PASSWORD('newpassword') where USER='root';

刷新权限:

FLUSH PRIVILEGES;

然后退出,重新登录:

quit

重新登录: 可以关掉之前的cmd1 窗口了。然后用net start mysql 启动服务

mysql -u root -p

出现输入密码提示,输入新的密码即可登录:

Enter password: ***********

显示登录信息: 成功 就一切ok了

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!