Windows下MySQL 5.7无法启动的解决方法

2016-12-24 17:36:26  windows无法启动mysql

问题描述:

从网上下了5.7 的MySQL,在bin目录下执行 start mysqld ,弹出个cmd窗口一闪就没了,也看不清是什么报错。mysqld --install安装了服务,也启动不了。

处理步骤:

1、打开事件查看器检查报错信息

Windows下MySQL 5.7无法启动的解决方法

2、网上查了,都说如果是 linux 需要执行 mysql_install_db;如果是Windows需要拷贝 user.frm user.MYD和user.MYI

3、不过,http://serverfault-com/questions/291126/mysql-fatal-error-cant-open-and-lock-privilege-tables-table-mysql-host-doe

这里面有人建议使用   mysqld --initialize

执行了下,报错:

C:\Program Files\MySQL\MySQL Server 5.7\bin>mysqld --initialize
2016-12-20T04:33:22.298853Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is
 deprecated. Please use --explicit_defaults_for_timestamp server option (see doc
umentation for more details).
2016-12-20T04:33:22.298853Z 0 [Warning] 'NO_ZERO_DATE', 'NO_ZERO_IN_DATE' and 'E
RROR_FOR_DIVISION_BY_ZERO' sql modes should be used with strict mode. They will
be merged with strict mode in a future release.
2016-12-20T04:33:22.298853Z 0 [Warning] 'NO_AUTO_CREATE_USER' sql mode was not s
et.
2016-12-20T04:33:22.303853Z 0 [ERROR] --initialize specified but the data direct
ory has files in it. Aborting.
2016-12-20T04:33:22.304853Z 0 [ERROR] Aborting

4、因为都是测试数据,我就直接把 datadir (我的是D:\MysqlData) 文件夹给删了。再次执行mysqld --initialize

C:\Program Files\MySQL\MySQL Server 5.7\bin>mysqld --initialize

5、启动服务(如果没有安装服务的话需要先 执行 mysqld --install)

C:\Program Files\MySQL\MySQL Server 5.7\bin>net start mysql

MySQL 服务正在启动 .

MySQL 服务已经启动成功。 

这种方法比起拷贝  user. 文件的要简单,不过需要清除所有数据,适合在自己的测试环境上使用。

Windows下MySQL 5.7无法启动的解决方法》阅读地址:http://www.haoshilao.net/13491/

最新图文教程: