# 数据库初始化 **Repository Path**: liumou_site/database-initialized ## Basic Information - **Project Name**: 数据库初始化 - **Description**: 通过指定SQL文件实现数据库的初始化操作 - **Primary Language**: Go - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2025-03-26 - **Last Updated**: 2025-03-26 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # 数据库初始化 #### 介绍 通过指定SQL文件实现数据库的初始化操作 #### 安装教程 1. 克隆仓库 ``` git clone https://gitee.com/liumou_site/database-initialized.git ``` 2. 编译程序(需安装Go 1.16+) ``` go build -o sql_import ``` 3. 查看帮助信息 ``` ./sql_import -h ``` #### 使用说明 **命令行参数**: ``` -user string Database username -password string Database password -host string Database host -port int Database port (default 3306) -dbname string Database name -file string SQL file path -force Force import even if tables exist ``` **使用示例**: ``` ./sql_import -user root -password 123456 -host 127.0.0.1 -port 3306 -dbname test -file init.sql ``` **数据库初始化策略**: 1. 默认检查目标库是否存在同名表 2. 使用-force参数强制覆盖已有表 3. 使用事务保证批量操作的原子性 4. 支持多语句SQL文件执行