http://www.cnblogs.com/zf2011/archive/2012/03/13/2393387.html

今天想做个小项目,决定用mysql数据库,但是好久没用mysql了,也忘掉了当时建库时root密码是什么了,找到了一篇文章,在这里记录下。

Windows下mysql忘记root密码的解决方法:

Mysql版本:5.1.55-community MySQL Community Server (GPL)

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

net stop mysql

或者在windows任务管理器中结束mysqld.exe进程,或者在控制面板,管理工具里面的服务找到mysql,将其停止服务。

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

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

注释:

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

"C:\Program Files\MySQL\MySQL Server 5.1\my.ini"指配置文件my.ini,一般在mysql安装目录里面。

如:

===============================================================================

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

110301 9:20:07 [Warning] '--default-character-set' is deprecated and will be removed in a future release. Please use '--character-set-server' instead.

110301 9:20:07 [Note] Plugin 'FEDERATED' is disabled.

110301 9:20:07 InnoDB: Initializing buffer pool, size = 46.0M

110301 9:20:07 InnoDB: Completed initialization of buffer pool

110301 9:20:07 InnoDB: Started; log sequence number 0 44233

110301 9:20:07 [Note] mysqld: ready for connections.

Version: '5.1.55-community' socket: '' port: 3306 MySQL Community Server (GPL)

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

输入命令:

mysql -uroot -p

出现:

Enter password:

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

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

如:

===============================================================================

Welcome to the MySQL monitor. Commands end with ; or \g.

Your MySQL connection id is 3

Server version: 5.1.55-community MySQL Community Server (GPL)

Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.

This software comes with ABSOLUTELY NO WARRANTY. This is free software,

and you are welcome to modify and redistribute it under the GPL v2 license

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>

===============================================================================

使用命令:

show databases;

显示已有数据库:

+--------------------+

| Database           |

+--------------------+

| information_schema |

| mysql              |

| test               |

+--------------------+

3 rows in set (0.00 sec)

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

use mysql;

使用命令更改root密码:

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

刷新权限:

FLUSH PRIVILEGES;

然后退出,重新登录:

quit

重新登录:

mysql -uroot -p

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

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

显示登录信息:

Welcome to the MySQL monitor. Commands end with ; or \g.

Your MySQL connection id is 9

Server version: 5.1.55-community MySQL Community Server (GPL)

Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.

This software comes with ABSOLUTELY NO WARRANTY. This is free software,

and you are welcome to modify and redistribute it under the GPL v2 license

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>

到这里root密码就已经修改成功了,用Ctrl+C将第一个cmd窗口结束,那样就会停止mysql服务,如:

=============================================================================== C:\Program Files\MySQL\MySQL Server 5.1\bin>mysqld --defaults-file="C:\Program F

iles\MySQL\MySQL Server 5.1\my.ini" --console --skip-grant-tables

110301 10:29:47 [Warning] '--default-character-set' is deprecated and will be re

moved in a future release. Please use '--character-set-server' instead.

110301 10:29:47 [Note] Plugin 'FEDERATED' is disabled.

110301 10:29:47 InnoDB: Initializing buffer pool, size = 46.0M

110301 10:29:47 InnoDB: Completed initialization of buffer pool

110301 10:29:48 InnoDB: Started; log sequence number 0 44233

110301 10:29:48 [Note] mysqld: ready for connections.

Version: '5.1.55-community' socket: '' port: 3306 MySQL Community Server (GPL)

(此处输入ctrl+c)

110301 10:30:58 [Note] mysqld: Normal shutdown

110301 10:30:58 InnoDB: Starting shutdown...

110301 10:31:03 InnoDB: Shutdown completed; log sequence number 0 44233

110301 10:31:03 [Note] mysqld: Shutdown complete

Mysql服务停止了,输入命令:

net start mysql,即可重新启动mysql服务,如:

===============================================================================

C:\Program Files\MySQL\MySQL Server 5.1\bin>net start mysql

MySQL 服务正在启动 .

MySQL 服务已经启动成功。

C:\Program Files\MySQL\MySQL Server 5.1\bin>

mysql忘记root密码连接本地库的更多相关文章

  1. MySQL 5.7 Command Line Client输入密码后闪退和windows下mysql忘记root密码的解决办法

    MySQL 5.7 Command Line Client输入密码后闪退的问题: 问题分析: 1.查看mysql command line client默认执行的一些参数.方法:开始->所有程序 ...

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

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

  3. mysql忘记root密码的解决方法

    Windows下mysql忘记root密码的解决方法 1. 首先检查mysql服务是否启动,若已启动则先将其停止服务,可在开始菜单的运行,使用命令:net stop mysql 或者在windows任 ...

  4. skip-grant-tables 修改linux的mysql忘记root密码

    skip-grant-tables 修改linux的mysql忘记root密码 今天修改mysql中的admin用户权限,在执行update user set host =' %' where use ...

  5. mysql忘记root密码解决办法

    最近项目中的数据库我放在了服务器上,但是今天突然不能用了,进入服务器查看,果然是数据库不能进去了,所以今天来分享一个mysql忘记root密码的解决方案: 1.让mysql不载入权限表,命令:mysq ...

  6. Ubuntu下MySQL忘记root密码重置

    MySQL忘记root密码肿么办?-_-|||   这种情况虽然不是很常见,但是有时长时间没有登录系统,还真会忘记密码.这时候,如果您能以系统管理员权限登陆密码,那还是有救的.放大招,将其重置即可. ...

  7. linux下mysql忘记root密码怎么办

    Linux下MySQL忘记root密码怎么办? Linux下MySQL忘记root密码怎么办? 1. 修改MySQL配置文件 默认MySQL的配置文件为/etc/my.cnf,在[mysqld]下面添 ...

  8. 附录:MySQL忘记root密码

    中小型规模网站集群架构:MySQL忘记root密码 : 矮哥linux运维群:93324526 前言 你忘记系统root密码的时候,你怎么解决的? 不就是single用户进行修改密码吗?这里原理是类似 ...

  9. MySQL忘记root密码不重启mysqld的方法

    MySQL忘记root密码不重启mysqld的方法   1.首先得有一个可以拥有修改权限的mysql数据库账号,当前的mysql实例账号(较低权限的账号,比如可以修改zabbix数据库)或者其他相同版 ...

随机推荐

  1. Android面试官:说说你对 Binder 驱动的了解?

    面试官提了一个问题:说说你对 binder 驱动的了解.这个问题虽有些 "面试造火箭" 的无奈,可难点就是亮点.价值所在,是筛选面试者的有效手段.如果让你回答,你能说出多少呢?我们 ...

  2. TotalCommander的两款目录插件

    CatalogMaker 与 DiskDir Extended 是两个用于生成文件夹目录的totalCmd插件. 将指定目录下所有文件.文件夹以指定格式存储在一个文本文件中,可作为EverCD+的轻量 ...

  3. Python语言系列-06-面向对象1

    楔子 #!/usr/bin/env python3 # author:Alnk(李成果) # 人狗大战例子引入面向对象 # 版本1 def hero(name, sex, hp, ce, level= ...

  4. 关于knn算法的总结思考

    更多的关于k近邻算法的思考 KNN(K- Nearest Neighbor)法即K最邻近法,数据挖掘分类技术中最简单的方法之一 对k近邻算法的总结: 优点部分 其可以解决分类问题,同时可以天然的解决多 ...

  5. [1.6W字]浏览器跨域请求的原理, 以及解决方法(可以纯前端实现) #flight.Archives011

    Title/ 浏览器跨域(CrossOrigin)请求的原理, 以及解决方案详细指南 #flight.Archives011 序: 最近看到又有一波新的创作活动了, 官方给出的话题中有一个" ...

  6. 关于Ajax异步提交登录及增删改查小项目制作-登录

    一.登录的完成 先导包jquery和MySql //异步提交 <script type="text/javascript" src="js/jquery-1.8.2 ...

  7. Nebula 2.5.0安装过程及遇到的坑

    2021年8月23日,Nebula 发布了最新版本:2.5.0,正好赶上新环境部署,记录一下安装过程及遇到的坑: 一.准备工作 以下安装使用nebula用户,搭建集群模式,一共三台机器:192.168 ...

  8. html,javascript,正则表达式

    正则表达式是对字符串操作的逻辑公式,用事先定好的一些特定字符组成一个"规则字符串",在用"规则字符串"对字符串进行过滤. ECMAScript 通过RegExp ...

  9. prism 的学习网站

    C#的学习网址: https://www.cnblogs.com/zh7791

  10. Git pull and push

    转自:https://blog.csdn.net/qq_41306423/article/details/101701991 关于 git pull 和 git pull origin develop ...