Enable six character MySQL passwords by default
This commit is contained in:
@@ -10,10 +10,12 @@ from .deployer import DeploymentConfig, build_deployment_plan, run_steps
|
||||
from .environment import EnvironmentCheck, check_environment, load_tool_paths, save_tool_paths
|
||||
from .installer import (
|
||||
MAVEN_VERSION,
|
||||
MYSQL_ROOT_PASSWORD,
|
||||
MYSQL_VERSION,
|
||||
TOMCAT_VERSION,
|
||||
build_install_command,
|
||||
install_maven,
|
||||
install_mysql,
|
||||
install_tomcat,
|
||||
recommend_jdk_version,
|
||||
run_install_command,
|
||||
@@ -54,7 +56,7 @@ class DeployWorkbench(tk.Tk):
|
||||
self.user_frontend_port = tk.StringVar(value="8082")
|
||||
self.admin_frontend_port = tk.StringVar(value="8081")
|
||||
self.mysql_user = tk.StringVar(value="root")
|
||||
self.mysql_password = tk.StringVar()
|
||||
self.mysql_password = tk.StringVar(value=MYSQL_ROOT_PASSWORD)
|
||||
self.mysql_database = tk.StringVar()
|
||||
self.output_dir = tk.StringVar()
|
||||
self.jdk_version = tk.StringVar(value="8")
|
||||
@@ -372,23 +374,37 @@ class DeployWorkbench(tk.Tk):
|
||||
mysql_note = ""
|
||||
if tool_name == "MySQL":
|
||||
mysql_note = (
|
||||
f"\n\n将安装 MySQL Community Server {MYSQL_VERSION} 及官方工具。首次安装后,请在部署配置中填写实际的 "
|
||||
"root 用户密码;程序不会生成、保存或显示默认数据库密码。"
|
||||
f"\n\n将安装 MySQL Community Server {MYSQL_VERSION},默认把 root 密码设置为 {MYSQL_ROOT_PASSWORD},"
|
||||
"并永久允许 6 位弱密码。MySQL 仅开放本机连接,不自动开放 Windows 防火墙端口。"
|
||||
)
|
||||
command_preview = " ".join(command).replace(
|
||||
f"root_passwd={MYSQL_ROOT_PASSWORD}", "root_passwd=******"
|
||||
)
|
||||
if not messagebox.askyesno(
|
||||
f"确认安装 {tool_name}",
|
||||
f"即将通过 winget 安装 {tool_name}。\n\n"
|
||||
f"命令: {' '.join(command)}"
|
||||
f"命令: {command_preview}"
|
||||
f"{mysql_note}\n\n"
|
||||
"安装可能需要管理员权限,并可能修改 PATH。是否继续?",
|
||||
):
|
||||
return
|
||||
self._append_log(f"开始安装 {tool_name}...")
|
||||
if tool_name == "MySQL":
|
||||
threading.Thread(target=self._install_mysql_worker, args=(command,), daemon=True).start()
|
||||
return
|
||||
threading.Thread(
|
||||
target=lambda: self.ui_queue.put(("install_done", (tool_name, run_install_command(command, self._thread_log)))),
|
||||
daemon=True,
|
||||
).start()
|
||||
|
||||
def _install_mysql_worker(self, command: list[str]) -> None:
|
||||
try:
|
||||
executable = install_mysql(command, self._thread_log)
|
||||
except Exception as exc:
|
||||
self.ui_queue.put(("mysql_install_done", (None, str(exc))))
|
||||
return
|
||||
self.ui_queue.put(("mysql_install_done", (executable, "")))
|
||||
|
||||
def install_maven_async(self) -> None:
|
||||
if not messagebox.askyesno(
|
||||
"确认安装 Maven",
|
||||
@@ -621,6 +637,18 @@ class DeployWorkbench(tk.Tk):
|
||||
self._append_log(f"Tomcat 路径已保存: {executable}")
|
||||
self.check_environment_async()
|
||||
self.after(1800, lambda: self._prompt_add_tool_after_install("Tomcat"))
|
||||
elif event == "mysql_install_done":
|
||||
executable, error = payload # type: ignore[misc]
|
||||
if error:
|
||||
self._append_log(f"MySQL 安装或配置失败: {error}")
|
||||
messagebox.showerror("MySQL 安装或配置失败", str(error))
|
||||
continue
|
||||
self.tool_path_vars["MySQL"].set(str(executable))
|
||||
self.save_tool_path_settings(silent=True)
|
||||
self.mysql_password.set(MYSQL_ROOT_PASSWORD)
|
||||
self._append_log(f"MySQL 路径已保存: {executable}")
|
||||
self.check_environment_async()
|
||||
self.after(1800, lambda: self._prompt_add_tool_after_install("MySQL"))
|
||||
self.after(120, self._drain_queue)
|
||||
|
||||
def _prompt_add_tool_after_install(self, tool_name: str) -> None:
|
||||
|
||||
Reference in New Issue
Block a user