Home  >  Article  >  Database  >  【Mysql】常用指令之忘记密码_MySQL

【Mysql】常用指令之忘记密码_MySQL

WBOY
WBOYOriginal
2016-06-01 13:02:041212browse

上一篇文章基本总结了下myql下通过指令怎么创建用户,详见:【Mysql】常用指令之——用户操作(创建,授权,修改,删除)

今天说下特殊情况,忘记密码了怎么办???

重装,删除配置等可以完成此操作。那不重装怎么办呢?

原理:

通过增加启动参数:--skip-grant-tables 跳过grant-tables启动数据库,这样就不需要密码就能进去了。

下面来玩玩:

linux下:

1、关闭mysql进程,应该都会哈比如:service mysql stop 或者 ps -ef | grep mysql kill (mysqlpid)还有rcmysqld stop 等等。

2、增加启动参数:可以编辑/etc/my.ini或者/etc/my.cnf文件,增加启动参数--skip-grant-tables 也可以用命令: /usr/bin/mysqld_safe --skip-grant-tables & 来启动mysql

3、无密码进入系统修改密码: mysql -u root -p 即可。

window下也是一样的只是操作不一样。

1、我的电脑右键》管理》服务》找到mysql 并停止 或者 win+R 运行cmd 然后运行 net stop mysql

2、利用--skip-grant-tables参数来启动数据库。

C:\Users\WJ>net stop mysql
MySQL 服务正在停止..
MySQL 服务已成功停止。

C:\Users\WJ>mysqld --skip-grant-tables
3、用root登陆吧,任意枉为 去吧。 

4、停止 再不通过此参数启动即可。

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn