Home  >  Article  >  Database  >  MySQL 5.6 root密码丢失,使用mysqld --skip-grant-tables_MySQL

MySQL 5.6 root密码丢失,使用mysqld --skip-grant-tables_MySQL

WBOY
WBOYOriginal
2016-05-30 17:11:051123browse

MySQL 5.6 root密码丢失,(window平台)使用mysqld –skip-grant-tables启动MySQL服务,出现警告:

 

[Warning] TIMESTAMP with implicit DEFAULT value is deprecated.Please use --explicit_defaults_for_timestamp server option (seedocumentation for more details)

解决方法:

 

Step1:

 

进 入cmd模式,输入命令:net stop mysql 停止开机启动的 mysql services(如果是手动启动可以跳过Step1,我的pc是开机启动),我电脑上的mysql services名字是mysql,你的名字可能不一样!, net stop xxx (xxx代表你的mysql services名字)

Step2:

 

找到mysql安装目录下的 my.ini文件,在[mysqld]下方添加:

 

explicit_defaults_for_timestamp = true

 

添加好后像这样:

[mysqld]

 

explicit_defaults_for_timestamp = true

Step3:

 

现在开始使用mysqld命令手动启动mysql services,既然是手动启动,肯定要为该命令指定启动配置文件my.ini的存放路径,我的路径是:D:\java\MySQL\ProgramData\MySQL Server 5.6

 

在cmd模式下输入:

 

mysqld --defaults-file="d:\java\MySQL\ProgramData\MySQL Server 5.6\my.ini" --skip-grant-tables

 

输入:

 

mysql -u root

 

可以看到已经进入mysql>状态下了,重新给root用户设置密码:

 

mysql>UPDATE mysql.user SET Password=PASSWORD("newpassword")  WHERE User='root' and Host='localhost';

Step4:

 

mysql>FLUSH PRIVILEGES;

 

加载权限表,让新密码生效!

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