Files
JGE-RS-SL-WEB/backend/database/init.sql

31 lines
1.3 KiB
SQL
Raw 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.
-- 梦幻西游一站式运营管理平台 - 数据库初始化脚本
-- MySQL 8.4 版本
-- 创建时间2025-12-27
-- 设置字符集
SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;
-- 后台用户表
CREATE TABLE IF NOT EXISTS admin_users (
id BIGINT PRIMARY KEY AUTO_INCREMENT COMMENT '用户ID',
username VARCHAR(50) UNIQUE NOT NULL COMMENT '用户名',
password_hash CHAR(60) NOT NULL COMMENT '密码哈希(bcrypt)',
role ENUM('super_admin', 'operator', 'viewer') NOT NULL DEFAULT 'viewer' COMMENT '角色super_admin-超级管理员, operator-操作员, viewer-查看者',
created_at DATETIME DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
updated_at DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
INDEX idx_username (username)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='后台用户表';
-- 插入默认超级管理员账号
-- 用户名admin
-- 密码admin123
-- 注意密码哈希需要使用bcrypt生成以下是admin123的bcrypt哈希值10轮
INSERT INTO admin_users (username, password_hash, role) VALUES
('admin', '$2b$10$Q1RH29Lsi4y/uq9ZIej1a.nRUv/7gNgdnga.tVStXGARE/J0rrF5K', 'super_admin');
-- 验证插入结果
SELECT * FROM admin_users;
SET FOREIGN_KEY_CHECKS = 1;