内容发布更新时间 : 2025/2/2 12:20:17星期一 下面是文章的全部内容请认真阅读。
MySql5.5忘记root密码的解决方法
操作系统:windows操作系统,xp或win7.
1.进入C:\\Program Files\\MySQL\\MySQL Server 5.5\\bin,新建cmd.bat文件,内容为 cmd.exe
双击cmd.bat,进入目录后停止mysql服务 e:\\mysql5.5\\bin>net stop mysql
注意:看看那任务管理器中是否有mysqld.exe进程,如有,kill them all. 2. 以不检查权限的方式启动mysql
e:\\mysql5.5\\bin>mysqld.exe --skip-grant-tables
你会看到窗口光标在下一行的第一个位置闪烁,这说明已经启动了,不需要管。 3. 新建一个命令行窗口同样进入到e:\\mysql5.5\\bin目录,启动mysql e:\\mysql5.5\\bin>mysql 4. 修改root密码 mysql>use mysql mysql>update user='root';
user
set
password=PASSWORD('new_password')
where
mysql>flush privileges; mysql>quit
5. 看看那任务管理器中是否有mysqld.exe进程,如有,kill them all. 6. 重启mysql,就可以用你设置新密码登陆 e:\\mysql5.5\\bin>net start mysql
e:\\mysql5.5\\bin>mysql -u root -pnew_password that's all .
默认密码是空的情况下修改密码
C:\\xampp\\mysql\\bin>
C:\\xampp\\mysql\\bin>mysql -u root
Welcome to the MySQL monitor. Commands end with ; or \\g. Your MySQL connection id is 1378
Server version: 5.5.25a MySQL Community Server (GPL)
Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners.
Type 'help;' or '\\h' for help. Type '\\c' to clear the current input statement.
mysql>SET PASSWORD FOR 'root'@'localhost' = PASSWORD('root'); Query OK, 0 rows affected (0.00 sec) mysql>flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql>quit;
Bye
C:\\xampp\\mysql\\bin>
或
Microsoft Windows [版本 5.2.3790] (C) 版权所有 1985-2003 Microsoft Corp. C:\\Documents and Settings\\Administrator>cd \\
C:\\>cd xampp
C:\\xampp>cd mysql
C:\\xampp\\mysql>cd bin