mysql忘记root密码连接本地库
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密码连接本地库的更多相关文章
- MySQL 5.7 Command Line Client输入密码后闪退和windows下mysql忘记root密码的解决办法
MySQL 5.7 Command Line Client输入密码后闪退的问题: 问题分析: 1.查看mysql command line client默认执行的一些参数.方法:开始->所有程序 ...
- windows下mysql忘记root密码的解决办法
今天早上 一朋友说自己的mysql 忘记root密码了 让我帮忙给看看,因为没有接触过mysql 所以从网上找了一下信息经我亲身实践 已经成功!mysql版本是5.1以下是从网上找的信息: 1. 首 ...
- mysql忘记root密码的解决方法
Windows下mysql忘记root密码的解决方法 1. 首先检查mysql服务是否启动,若已启动则先将其停止服务,可在开始菜单的运行,使用命令:net stop mysql 或者在windows任 ...
- skip-grant-tables 修改linux的mysql忘记root密码
skip-grant-tables 修改linux的mysql忘记root密码 今天修改mysql中的admin用户权限,在执行update user set host =' %' where use ...
- mysql忘记root密码解决办法
最近项目中的数据库我放在了服务器上,但是今天突然不能用了,进入服务器查看,果然是数据库不能进去了,所以今天来分享一个mysql忘记root密码的解决方案: 1.让mysql不载入权限表,命令:mysq ...
- Ubuntu下MySQL忘记root密码重置
MySQL忘记root密码肿么办?-_-||| 这种情况虽然不是很常见,但是有时长时间没有登录系统,还真会忘记密码.这时候,如果您能以系统管理员权限登陆密码,那还是有救的.放大招,将其重置即可. ...
- linux下mysql忘记root密码怎么办
Linux下MySQL忘记root密码怎么办? Linux下MySQL忘记root密码怎么办? 1. 修改MySQL配置文件 默认MySQL的配置文件为/etc/my.cnf,在[mysqld]下面添 ...
- 附录:MySQL忘记root密码
中小型规模网站集群架构:MySQL忘记root密码 : 矮哥linux运维群:93324526 前言 你忘记系统root密码的时候,你怎么解决的? 不就是single用户进行修改密码吗?这里原理是类似 ...
- MySQL忘记root密码不重启mysqld的方法
MySQL忘记root密码不重启mysqld的方法 1.首先得有一个可以拥有修改权限的mysql数据库账号,当前的mysql实例账号(较低权限的账号,比如可以修改zabbix数据库)或者其他相同版 ...
随机推荐
- C语言运算符(关系运算符)+(逻辑运算符)
下表显示了 C 语言支持的所有关系运算符.假设变量 A 的值为 10,变量 B 的值为 20,则: 实列: 1 #include <stdio.h> 2 3 int main() 4 { ...
- 深入理解Https如何保证通信安全
作为一名ABC搬运工,我相信很多人都知道Https,也都知道它是用来保证通信安全的,但是如果你没有深入了解过Https,可能并不知道它是如何保证通信安全的.我也是借着这次机会,和大家分享下我深入了解的 ...
- 探讨UE4中的UBT和UHT
前言 UBT和UHT是编译工具,谁定义的呢,虚幻引擎自己定义的,拿来做什么呢,UBT和UHT是UE4用来简化多平台编译,去除用户自定义平台编译项目的操作 我们写的UE4代码不是标准的C++代码,是基于 ...
- DVWA靶场之File Inclusion(文件包含)通关
文件包含,未经过严格过滤,将一些恶意构造带入了包含函数,可以使用一些包含函数来包含一些其他乱七八糟的东西,要么导致任意文件读取,要么命令执行 文件包含包括远程文件包含(RFI)和本地文件包含(LFI) ...
- 题解—P2218 [HAOI2007]覆盖问题
一道不错的题,主要就是一个思路点,想到就行了,想不到就一直卡着. 看完题解之后发现挺简单,实际上自己挣扎半天也咩有想到. 一开始想类比成一维之后贪心,后来被同机房大佬 \(hack\) 掉了. sol ...
- pytorch之对预训练的bert进行剪枝
大体过程 对层数进行剪枝 1.加载预训练的模型: 2.提取所需要层的权重,并对其进行重命名.比如我们想要第0层和第11层的权重,那么需要将第11层的权重保留下来并且重命名为第1层的名字: 3.更改模型 ...
- WPF 中的 Command 命令
<Window x:Class="CommandDemo.MainWindow" xmlns="http://schemas.microsoft.com/winfx ...
- Mysql---mysqldump参数详细说明(转)
Mysqldump参数大全(参数来源于mysql5.5.19源码) mysqldump.exe一般会默认安装在C:\Program Files\MySQL\MySQL Server 5.5\bin 参 ...
- swagger2 注解说明文档
@Api:用于类上,说明该类的作用.可以标记一个Controller类做为swagger 文档资源 @Api(value = "xxx", description = " ...
- java 搞笑注释
// _ooOoo_ // o8888888o // 88" . "88 // (| -_- |) // O\ = /O // ____/`---'\____ // . ' \\| ...