找回密码
 注册
搜索
[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
查看: 18309|回复: 1

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

[复制链接]
发表于 2022-4-19 19:57:44 | 显示全部楼层 |阅读模式
在安装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
复制代码
发表于 2022-4-21 16:50:54 | 显示全部楼层
  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%
复制代码
您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|手机版|小黑屋|批处理之家 ( 渝ICP备10000708号 )

GMT+8, 2026-3-20 02:02 , Processed in 0.017106 second(s), 8 queries , File On.

Powered by Discuz! X3.5

© 2001-2026 Discuz! Team.

快速回复 返回顶部 返回列表