D:\mysql-8.0.41-winx64\mysql-8.0.41-winx64\bin>mysqld --initialize
mysqld: Can't create/write to file 'D:\mysql-8.0.41-winx64\mysql-8.0.41-winx6in\is_writable' (OS errno 2 - No such file or directory)
2025-03-12T07:00:06.611895Z 0 [Warning] [MY-010915] [Server] '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.
2025-03-12T07:00:06.612139Z 0 [System] [MY-013169] [Server] D:\mysql-8.0.41-winx64\mysql-8.0.41-winx64\bin\mysqld.exe (mysqld 8.0.41) initializing of server in progress as process 10616
2025-03-12T07:00:06.613346Z 0 [Warning] [MY-013242] [Server] --character-set-server: 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous.
2025-03-12T07:00:06.614438Z 0 [ERROR] [MY-010460] [Server] --initialize specified but the data directory exists and is not writable. Aborting.
2025-03-12T07:00:06.614502Z 0 [ERROR] [MY-010187] [Server] Could not open file 'D:\mysql-8.0.41-winx64\mysql-8.0.41-winx6in\long7351.err' for error logging: Permission denied
2025-03-12T07:00:06.615043Z 0 [ERROR] [MY-013236] [Server] The designated data directory D:\mysql-8.0.41-winx64\mysql-8.0.41-winx6in\ is unusable. You can remove all files that the server added to it.
2025-03-12T07:00:06.615194Z 0 [ERROR] [MY-010119] [Server] Aborting
2025-03-12T07:00:06.615504Z 0 [System] [MY-010910] [Server] D:\mysql-8.0.41-winx64\mysql-8.0.41-winx64\bin\mysqld.exe: Shutdown complete (mysqld 8.0.41) MySQL Community Server - GPL.
安装mysql后找不到目录,原因是路径里有windows风格的 " \ "。路径要改成unix风格的 " / ",而不是windows的风格。正确的如下:
有时候我发现\t 有转义的成空格情况。原理是 \t 在数据传输的时候被转义成了空格。
如果仍有问题
可以尝试mysqld --initialize --console --datadir="D:\soft\mysql-8.0.41-winx64\mysql-8.0.41-winx64\data"
>mysqld --initialize --console --datadir="D:\soft\mysql-8.0.41-winx64\mysql-8.0.41-winx64\data"
2025-03-12T08:33:24.030503Z 0 [Warning] [MY-010915] [Server] '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.
2025-03-12T08:33:24.030709Z 0 [System] [MY-013169] [Server] D:\soft\mysql-8.0.41-winx64\mysql-8.0.41-winx64\bin\mysqld.exe (mysqld 8.0.41) initializing of server in progress as process 15476
2025-03-12T08:33:24.047238Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2025-03-12T08:33:24.414644Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.