现在的位置: 首页 > 综合 > 正文

mysql忘记密码 如何解决

2013年03月26日 ⁄ 综合 ⁄ 共 1465字 ⁄ 字号 评论关闭

解决mysql忘记密码的办法

 

如果是windows环境下
C:\wamp\bin\mysql\mysql5.5.20\bin>mysqld  --defaults-file="C:\wamp\bin\MySQL\mys
ql5.5.20\my.ini" --console --skip-grant-tables

linux环境下的话就运行:

# /etc/init.d/mysql stop
# mysqld_safe --user=mysql --skip-grant-tables --skip-networking &

如见到:

Version: '5.5.20'  socket: ''  port: 3306  MySQL Community Server (GPL)

此时说明成功了,需要别开一个窗口,执行如下步逐。

Microsoft Windows [版本 6.1.7601]
版权所有 (c) 2009 Microsoft Corporation。保留所有权利。

C:\wamp\bin\mysql\mysql5.5.20\bin>mysql -uroot mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.5.20 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> UPDATE user SET Password=PASSWORD('111111') where USER='root';
Query OK, 3 rows affected (0.00 sec)
Rows matched: 3  Changed: 3  Warnings: 0

mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.01 sec)

mysql> exit
Bye

C:\wamp\bin\mysql\mysql5.5.20\bin>mysql -uroot -p
Enter password: ******
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.5.20 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>

见面上面提示就知道密码修改成功了吧!

 

抱歉!评论已关闭.