问题现象
服务器启动后Mysql服务启动异常,通过分析数据目录下的报错信息确认:
2023-06-12T05:55:28.462487Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2023-06-12T05:55:28.550103Z 0 [Warning] 'NO_ZERO_DATE', 'NO_ZERO_IN_DATE' and 'ERROR_FOR_DIVISION_BY_ZERO' sql modes should be used with strict mode. They will be merged with strict mode in a future release.
2023-06-12T05:55:28.760832Z 0 [Note] C:\Program Files\MySQL\MySQL Server 5.7\bin\mysqld.exe (mysqld 5.7.17-log) starting as process 1832 ...
2023-06-12T05:55:32.836776Z 0 [Note] InnoDB: Mutexes and rw_locks use Windows interlocked functions
2023-06-12T05:55:32.836776Z 0 [Note] InnoDB: Uses event mutexes
2023-06-12T05:55:32.836776Z 0 [Note] InnoDB: _mm_lfence() and _mm_sfence() are used for memory barrier
2023-06-12T05:55:32.836776Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.3
2023-06-12T05:55:33.221428Z 0 [Note] InnoDB: Number of pools: 1
2023-06-12T05:55:33.497028Z 0 [Note] InnoDB: Not using CPU crc32 instructions
2023-06-12T05:56:46.686872Z 0 [ERROR] InnoDB: Unable to create temporary file; errno: 0
2023-06-12T05:56:46.687873Z 0 [ERROR] InnoDB: Plugin initialization aborted with error Generic error
2023-06-12T05:56:46.687873Z 0 [ERROR] Plugin 'InnoDB' init function returned error.
2023-06-12T05:56:46.688874Z 0 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
2023-06-12T05:56:46.688874Z 0 [ERROR] Failed to initialize plugins.
2023-06-12T05:56:46.688874Z 0 [ERROR] Aborting
解决办法
通过对“Unable to create temporary file; errno: 0”问题排查了,无法生成临时文件,尝试了修改my.ini 增加tempdir配置临时文件路径
tmpdir=C:\ProgramData\MySQL\temp
重启仍然报错,网上有说文件路径"“要使用”\"斜杠替换
datadir=C:\\ProgramData\\MySQL\\data
tmpdir=C:\\ProgramData\\MySQL\\temp
修改后重启mysql服务,启动服务正常,问题解决;