2 回答

TA贡献1821条经验 获得超4个赞
proc.waitFor(); 此语句应出现在BufferedReader语句之前,并在输入流阅读器中传递。注意:Process.waitFor()方法暂停当前线程,直到您的进程有机会完成。然后使用BufferReader可以读取输出。

TA贡献1864条经验 获得超6个赞
当我在你的程序的进程命令行args中使用mysqld start时,问题似乎是你传递的命令。我能够看到ouptut。所以问题在于您传递的CLI命令。建议手动运行它并查看打印输出。
String[] command = {"C:\\Users\\userid\\Downloads\\mysql-5.7.13-winx64\\mysql-5.7.13-winx64\\bin\\mysqld.exe", "--console"};
样本输出:
C:\Users\userid\other\stk-overflow>java ProcessDemo
2019-05-13T00:57:04.191518Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2019-05-13T00:57:04.191518Z 0 [Warning] 'NO_AUTO_CREATE_USER' sql mode was not set.
2019-05-13T00:57:04.191518Z 0 [Warning] Insecure configuration for --secure-file-priv: Current value does not restrict location of generated files. Consider setting it to a valid, non-empty path.
2019-05-13T00:57:04.191518Z 0 [Note] C:\Users\userid\Downloads\mysql-5.7.13-winx64\mysql-5.7.13-winx64\bin\mysqld.exe (mysqld 5.7.13) starting as process 21604 ...
2019-05-13T00:57:04.201520Z 0 [Note] InnoDB: Mutexes and rw_locks use Windows interlocked functions
2019-05-13T00:57:04.202742Z 0 [Note] InnoDB: Uses event mutexes
2019-05-13T00:57:04.203516Z 0 [Note] InnoDB: _mm_lfence() and _mm_sfence() are used for memory barrier
2019-05-13T00:57:04.203516Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.3
2019-05-13T00:57:04.204517Z 0 [Note] InnoDB: Number of pools: 1
2019-05-13T00:57:04.205519Z 0 [Note] InnoDB: Not using CPU crc32 instructions
2019-05-13T00:57:04.209518Z 0 [Note] InnoDB: Initializing buffer pool, total size = 128M, instances = 1, chunk size = 128M
添加回答
举报