Files
zkxw/docs/sql/2026-10-16-reset-weak-password-111111.sql
2026-10-17 11:46:53 +08:00

47 lines
2.1 KiB
SQL
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
-- =============================================================================
-- 弱密码刷新说明:111111 → Zkxw@123
-- 日期:2026-10-16
-- =============================================================================
--
-- 重要:sys_user.password 存储 bcrypt 哈希(每次盐随机),
-- 不能用下列语句命中弱密码用户:
-- WHERE password = '111111' -- 无效
-- WHERE password LIKE '%111111%' -- 无效
--
-- 推荐:用 Python 脚本,并通过变量指定目标库(勿依赖本机默认 .env 误连生产)。
--
-- cd backend && source venv/bin/activate
--
-- # 方式 A:完整 URL
-- python scripts/reset_weak_password_111111.py \
-- --database-url 'mysql+pymysql://USER:PASS@HOST:3306/DBNAME' --dry-run
--
-- # 方式 B:分项变量
-- python scripts/reset_weak_password_111111.py \
-- --db-host HOST --db-port 3306 --db-user USER --db-password 'PASS' --db-name DBNAME --dry-run
--
-- # 方式 C:指定环境文件
-- python scripts/reset_weak_password_111111.py --env-file ./.env.test --dry-run
--
-- # 正式写入:去掉 --dry-run
--
-- 脚本行为:校验 del_flag=0 的用户口令是否为明文 111111(含停用账号),
-- 命中则更新为 Zkxw@123 的新 bcrypt 哈希。
--
-- =============================================================================
-- 以下仅为「已知单个用户 id」时的手工 UPDATE 模板。
-- 哈希由本机生成示例(明文 Zkxw@123,bcrypt cost 12),部署前请用 Python 重新生成:
-- python -c "from app.core.security import get_password_hash; print(get_password_hash('Zkxw@123'))"
-- =============================================================================
-- 示例哈希(仅供手工单用户更新参考;批量请用脚本):
-- $2b$12$ULvPCr6g9IUmI8K7nlGU5emk7hupaAz4WgFdEoQBe935Wh1pVYKCK
-- UPDATE sys_user
-- SET password = '$2b$12$ULvPCr6g9IUmI8K7nlGU5emk7hupaAz4WgFdEoQBe935Wh1pVYKCK',
-- update_time = NOW()
-- WHERE id = '<user_id>'
-- AND del_flag = 0;
-- 执行前请备份 sys_user;执行后通知用户使用新密码并建议登录后自行修改。