windows下忘记mysql的root用户密码详细解决方法.docx
- 文档编号:17780262
- 上传时间:2023-08-03
- 格式:DOCX
- 页数:10
- 大小:130.84KB
windows下忘记mysql的root用户密码详细解决方法.docx
《windows下忘记mysql的root用户密码详细解决方法.docx》由会员分享,可在线阅读,更多相关《windows下忘记mysql的root用户密码详细解决方法.docx(10页珍藏版)》请在冰点文库上搜索。
windows下忘记mysql的root用户密码详细解决方法
Windows下mysql忘记root密码的解决方法:
Mysql版本:
5.1.55-communityMySQLCommunityServer(GPL)
1、首先检查mysql服务是否启动,若已启动则先将其停止服务,可在开始菜单的运行,使用命令:
netstopmysql
或者在windows任务管理器中结束mysqld.exe进程,或者在控制面板,管理工具里面的服务找到mysql,将其停止服务。
打开第一个cmd窗口,切换到mysql的bin目录,运行命令:
mysqld--defaults-file="C:
\ProgramFiles\MySQL\MySQLServer5.1\my.ini"--console--skip-grant-tables
注释:
该命令通过跳过权限安全检查,开启mysql服务,这样连接mysql时,可以不用输入用户密码。
"C:
\ProgramFiles\MySQL\MySQLServer5.1\my.ini"指配置文件my.ini,一般在mysql安装目录里面。
如:
===============================================================================
C:
\ProgramFiles\MySQL\MySQLServer5.1\bin>mysqld--defaults-file="C:
\ProgramFiles\MySQL\MySQLServer5.1\my.ini"--console--skip-grant-tables
1103019:
20:
07[Warning]'--default-character-set'isdeprecatedandwillberemovedinafuturerelease.Pleaseuse'--character-set-server'instead.
1103019:
20:
07[Note]Plugin'FEDERATED'isdisabled.
1103019:
20:
07InnoDB:
Initializingbufferpool,size=46.0M
1103019:
20:
07InnoDB:
Completedinitializationofbufferpool
1103019:
20:
07InnoDB:
Started;logsequencenumber044233
1103019:
20:
07[Note]mysqld:
readyforconnections.
Version:
'5.1.55-community'socket:
''port:
3306MySQLCommunityServer(GPL)
2、打开第二个cmd窗口,连接mysql:
输入命令:
mysql-uroot-p
出现:
Enterpassword:
在这里直接回车,不用输入密码。
然后就就会出现登录成功的信息,
如:
===============================================================================
WelcometotheMySQLmonitor.Commandsendwith;or\g.
YourMySQLconnectionidis3
Serverversion:
5.1.55-communityMySQLCommunityServer(GPL)
Copyright(c)2000,2010,Oracleand/oritsaffiliates.Allrightsreserved.
ThissoftwarecomeswithABSOLUTELYNOWARRANTY.Thisisfreesoftware,
andyouarewelcometomodifyandredistributeitundertheGPLv2license
Type'help;'or'\h'forhelp.Type'\c'toclearthecurrentinputstatement.
mysql>
===============================================================================
使用命令:
showdatabases;
显示已有数据库:
+--------------------+
|Database|
+--------------------+
|information_schema|
|mysql|
|test|
+--------------------+
3rowsinset(0.00sec)
使用命令切换到mysql数据库:
usemysql;
使用命令更改root密码:
UPDATEuserSETPassword=PASSWORD('newpassword')whereUSER='root';
刷新权限:
FLUSHPRIVILEGES;
然后退出,重新登录:
quit
重新登录:
mysql-uroot-p
出现输入密码提示,输入新的密码即可登录:
Enterpassword:
***********
显示登录信息:
WelcometotheMySQLmonitor.Commandsendwith;or\g.
YourMySQLconnectionidis9
Serverversion:
5.1.55-communityMySQLCommunityServer(GPL)
Copyright(c)2000,2010,Oracleand/oritsaffiliates.Allrightsreserved.
ThissoftwarecomeswithABSOLUTELYNOWARRANTY.Thisisfreesoftware,
andyouarewelcometomodifyandredistributeitundertheGPLv2license
Type'help;'or'\h'forhelp.Type'\c'toclearthecurrentinputstatement.
mysql>
到这里root密码就已经修改成功了,用Ctrl+C将第一个cmd窗口结束,那样就会停止mysql服务,如:
===============================================================================C:
\ProgramFiles\MySQL\MySQLServer5.1\bin>mysqld--defaults-file="C:
\ProgramF
iles\MySQL\MySQLServer5.1\my.ini"--console--skip-grant-tables
11030110:
29:
47[Warning]'--default-character-set'isdeprecatedandwillbere
movedinafuturerelease.Pleaseuse'--character-set-server'instead.
11030110:
29:
47[Note]Plugin'FEDERATED'isdisabled.
11030110:
29:
47InnoDB:
Initializingbufferpool,size=46.0M
11030110:
29:
47InnoDB:
Completedinitializationofbufferpool
11030110:
29:
48InnoDB:
Started;logsequencenumber044233
11030110:
29:
48[Note]mysqld:
readyforconnections.
Version:
'5.1.55-community'socket:
''port:
3306MySQLCommunityServer(GPL)
(此处输入ctrl+c)
11030110:
30:
58[Note]mysqld:
Normalshutdown
11030110:
30:
58InnoDB:
Startingshutdown...
11030110:
31:
03InnoDB:
Shutdowncompleted;logsequencenumber044233
11030110:
31:
03[Note]mysqld:
Shutdowncomplete
Mysql服务停止了,输入命令:
netstartmysql,即可重新启动mysql服务,如:
===============================================================================
C:
\ProgramFiles\MySQL\MySQLServer5.1\bin>netstartmysql
MySQL服务正在启动.
MySQL服务已经启动成功。
C:
\ProgramFiles\MySQL\MySQLServer5.1\bin>
===============================================================================
全部流程的操作信息,如下:
停止mysql服务方法1:
停止mysql服务方法2:
停止mysql服务方法3:
第一个CMD窗口:
===============================================================================
C:
\ProgramFiles\MySQL\MySQLServer5.1\bin>mysqld--defaults-file="C:
\ProgramFiles\MySQL\MySQLServer5.1\my.ini"--console--skip-grant-tables
1103019:
20:
07[Warning]'--default-character-set'isdeprecatedandwillbere
movedinafuturerelease.Pleaseuse'--character-set-server'instead.
1103019:
20:
07[Note]Plugin'FEDERATED'isdisabled.
1103019:
20:
07InnoDB:
Initializingbufferpool,size=46.0M
1103019:
20:
07InnoDB:
Completedinitializationofbufferpool
1103019:
20:
07InnoDB:
Started;logsequencenumber044233
1103019:
20:
07[Note]mysqld:
readyforconnections.
Version:
'5.1.55-community'socket:
''port:
3306MySQLCommunityServer(GPL)
===============================================================================
第二个CMD窗口:
===============================================================================
MicrosoftWindowsXP[版本5.1.2600]
(C)版权所有1985-2001MicrosoftCorp.
C:
\DocumentsandSettings\Administrator>mysql-uroot-p
Enterpassword:
WelcometotheMySQLmonitor.Commandsendwith;or\g.
YourMySQLconnectionidis3
Serverversion:
5.1.55-communityMySQLCommunityServer(GPL)
Copyright(c)2000,2010,Oracleand/oritsaffiliates.Allrightsreserved.
ThissoftwarecomeswithABSOLUTELYNOWARRANTY.Thisisfreesoftware,
andyouarewelcometomodifyandredistributeitundertheGPLv2license
Type'help;'or'\h'forhelp.Type'\c'toclearthecurrentinputstatement.
mysql>showdatabases;
+--------------------+
|Database|
+--------------------+
|information_schema|
|mysql|
|test|
+--------------------+
3rowsinset(0.00sec)
mysql>usemysql;
Databasechanged
mysql>UPDATEuserSETPassword=PASSWORD('newpassword')whereUSER='root';
QueryOK,2rowsaffected(0.03sec)
Rowsmatched:
2Changed:
2Warnings:
0
mysql>FLUSHPRIVILEGES;
QueryOK,0rowsaffected(0.00sec)
mysql>quit
Bye
C:
\DocumentsandSettings\Administrator>mysql-uroot-p
Enterpassword:
***********
WelcometotheMySQLmonitor.Commandsendwith;or\g.
YourMySQLconnectionidis9
Serverversion:
5.1.55-communityMySQLCommunityServer(GPL)
Copyright(c)2000,2010,Oracleand/oritsaffiliates.Allrightsreserved.
ThissoftwarecomeswithABSOLUTELYNOWARRANTY.Thisisfreesoftware,
andyouarewelcometomodifyandredistributeitundertheGPLv2license
Type'help;'or'\h'forhelp.Type'\c'toclearthecurrentinputstatement.
mysql>
===============================================================================
结束第一个窗口,输入ctrl+c命令停止mysql服务:
C:
\ProgramFiles\MySQL\MySQLServer5.1\bin>mysqld--defaults-file="C:
\ProgramFiles\MySQL\MySQLServer5.1\my.ini"--console--skip-grant-tables
11030110:
29:
47[Warning]'--default-character-set'isdeprecatedandwillbere
movedinafuturerelease.Pleaseuse'--character-set-server'instead.
11030110:
29:
47[Note]Plugin'FEDERATED'isdisabled.
11030110:
29:
47InnoDB:
Initializingbufferpool,size=46.0M
11030110:
29:
47InnoDB:
Completedinitializationofbufferpool
11030110:
29:
48InnoDB:
Started;logsequencenumber044233
11030110:
29:
48[Note]mysqld:
readyforconnections.
Version:
'5.1.55-community'socket:
''port:
3306MySQLCommunityServer(GPL)
(此处输入ctrl+c)
11030110:
30:
58[Note]mysqld:
Normalshutdown
11030110:
30:
58InnoDB:
Startingshutdown...
11030110:
31:
03InnoDB:
Shutdowncompleted;logsequencenumber044233
11030110:
31:
03[Note]mysqld:
Shutdowncomplete
重新启动mysql服务:
C:
\ProgramFiles\MySQL\MySQLServer5.1\bin>netstartmysql
MySQL服务正在启动.
MySQL服务已经启动成功。
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- windows 忘记 mysql root 用户密码 详细 解决方法