Board logo

标题: [文本处理] 批处理安装mysql如何截取生成的随机密码并保存便于后续调用? [打印本页]

作者: xuc    时间: 2022-4-19 19:57     标题: 批处理安装mysql如何截取生成的随机密码并保存便于后续调用?

在安装mysql时,输入mysqld --initialize --console后,会生成一个随机密码(最后12位),请问该如何截取这12位密码并保存,后续调用?
  1. D:\mysql-8.0.28-winx64\mysql-8.0.28-winx64\bin>mysqld --initialize --console
  2. 2022-04-19T11:45:10.951279Z 0 [Warning] [MY-010918] [Server] 'default_authentication_plugin' is deprecated and will be removed in a future release. Please use authentication_policy instead.
  3. 2022-04-19T11:45:10.951298Z 0 [System] [MY-013169] [Server] D:\mysql-8.0.28-winx64\mysql-8.0.28-winx64\bin\mysqld.exe (mysqld 8.0.28) initializing of server in progress as process 14012
  4. 2022-04-19T11:45:10.951379Z 0 [ERROR] [MY-010338] [Server] Can't find error-message file 'D:\mysql-8.0.26-winx64\mysql-8.0.26-winx64\share\errmsg.sys'. Check error-message file location and 'lc-messages-dir' configuration directive.
  5. 2022-04-19T11:45:10.990057Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
  6. 2022-04-19T11:45:11.514595Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
  7. 2022-04-19T11:45:12.296844Z 0 [Warning] [MY-013829] [Server] Missing data directory for ICU regular expressions: D:\mysql-8.0.26-winx64\mysql-8.0.26-winx64\lib\private\.
  8. 2022-04-19T11:45:13.580235Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: C6lGXsJfk,4D
复制代码

作者: idwma    时间: 2022-4-21 16:50

  1. for /f "delims=" %%i in ('mysqld --initialize --console') do set "p=%%i"
  2. for /f "delims=" %%i in ('echo;%p: =&echo;%') do set "p=%%i"
  3. echo %p%
复制代码





欢迎光临 批处理之家 (http://bbs.bathome.net/) Powered by Discuz! 7.2