步骤如下:
1.停止mysql服务(以管理员身份,在cmd命令行下运行) net stop mysql

D:\>net stop mysql 
MySQL 服务正在停止.
MySQL 服务已成功停止。 2.使用 mysqld –skip-grant-tables 命令启动mysql数据库
D:\>mysqld --skip-grant-tables

3.新开一个cmd窗口,进行如下操作

D:\>mysql -uroot
Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 1 Server version: 5.1.26-rc-community MySQL Community Server (GPL) Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> update mysql.user set password=password('root') where user='root';
Query OK, 1 row affected (0.02 sec) Rows matched: 2 Changed: 1 Warnings: 0
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec) mysql>

4.打开任务管理器,停止mysql,mysqld进程,使用net start mysql启动mysqld服务,就可以使用root用户 root密码进入数据库了

mysql -uroot -proot

补充说明:
1.mysqld使用说明可以使用如下命令获取查看:

mysqld --verbose --help > d:\mysqld_help.txt

帮助中–skip-grant-tables的帮助为:

--skip-grant-tables Start without grant tables. This gives all users FULL ACCESS to all tables!

所以我们可以使用mysql -uroot而不用密码直接登陆mysql,而且可以修改任何表。

2.如果没有配置mysql的环境变量,需要cd到mysql的bin目录执行上面的命令。
3.可参考:http://www.kuqin.com/database/20080306/4249.html,但是5.1可能没有mysqld-nt命令,其实mysqld就是对应的mysqld-nt命令。

最新文章

  1. android标题栏上面弹出提示框(二) PopupWindow实现,带动画效果
  2. Error: Could not find the required version of the Java(TM) 2 Runtime Environment in'(null)'.
  3. mongodb群集
  4. NOIP2016普及组
  5. PHP_Memcache函数详解
  6. redhat6.3安装MySQL-server-5.6.13-1.el6.x86_64.rpm
  7. 9. Linux远程登录
  8. 热烈庆祝杨学明老师为苏宁、中兴、烽火、CNNIC、创维、金立、中航信等知名企业提供培训和咨询服务!
  9. MeshCombineUtility.cs method `GetTriangleStrip' of type `UnityEngine.Mesh' could be found
  10. ESP8266例程
  11. 慎用memset();
  12. python开源项目及示例代码
  13. Android -------- eclipse平台上的单元测试框架
  14. C++多态的实现原理
  15. 关于 dos 下 npm 命令的使用
  16. 编译在docker alpine中可用的go程序
  17. apache与tomcat负载集群集成方法配置
  18. python 中argparse 实例解析
  19. KindEditor的使用
  20. 【学习】CodeUi

热门文章

  1. .NET Framework(CLI,CLS,CTS,CLR,FCL,BCL)
  2. 嵌套的SQL另外一种写法
  3. PlusOne
  4. linux service start|stop|restart
  5. ssh登录CentOS服务器(Aliyun)
  6. 卸载oracle11g
  7. python 实现简单点名程序
  8. mybatis 批量修改接口的几种实现方式
  9. 通过 HTTP 请求加载远程数据(ajax,axios)
  10. HostFileChangeMonitor