ITPub博客

首页 > 数据库 > MySQL > mysql忘记root密码

mysql忘记root密码

原创 MySQL 作者:dotaddjj 时间:2012-07-09 18:20:00 0 删除 编辑

Windows上忘记root密码登陆

C:Userspc>net stop mysql

MySQL 服务正在停止.

MySQL 服务已成功停止。

C:Userspc>e:

E:>cd E:Program FilesMySQLMySQL Server 5.0bin

E:Program FilesMySQLMySQL Server 5.0bin>mysqld-nt --skip-grant-tables

在另一个cmd下进行如下操作:

E:Program FilesMySQLMySQL Server 5.0bin>mysql -u root

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

Your MySQL connection id is 2 to server version: 5.0.22-community-nt

Type 'help;' or 'h' for help. Type 'c' to clear the buffer.

mysql> show databases;

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

| Database |

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

| information_schema |

| mysql |

| root |

| test |

| xiaoyu |

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

5 rows in set (0.11 sec)

mysql> use mysql

Database changed

mysql> update user set password=password('xiaoyu') where user='root';

Query OK, 0 rows affected (0.00 sec)

Rows matched: 2 Changed: 0 Warnings: 0

mysql> flush privileges;

Query OK, 0 rows affected (0.01 sec)

修改生效了,此时重启mysql服务需要先关闭进程mysql-nt.exe进程,然后才能net start mysql。

下面一种方法通用与windows和linux上mysql修改root密码。

修改mysql的初始化文件添加

Skip-grant-tables

然后重启mysql服务即可跳过密码验证,后面修改root密码和前面一样,修改完后去掉skip-grant-tables。

[@more@]

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/25362835/viewspace-1058771/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论
  • 博文量
    220
  • 访问量
    1662967