# 轻量级MySQL迁移工具 **Repository Path**: consolelog/lightweight-mysql-migrate-tools ## Basic Information - **Project Name**: 轻量级MySQL迁移工具 - **Description**: 轻量级MySQL迁移工具 - **Primary Language**: Java - **License**: MIT - **Default Branch**: master - **Homepage**: https://consolelog.gitee.io/lightweight-mysql-migrate-tools/ - **GVP Project**: No ## Statistics - **Stars**: 60 - **Forks**: 30 - **Created**: 2019-11-22 - **Last Updated**: 2025-06-06 ## Categories & Tags **Categories**: dbmanager **Tags**: None ## README = 轻量级MySQL迁移工具 :toc: left :docinfo: shared :stylesheet: ./css/adoc-github.css :toclevels: 4 :nofooter: :version: ${版本号} :sourcedir: mysql-migrate/src :javadir: {sourcedir}/main/java :testdir: {sourcedir}/test/java :git-url: https://gitee.com/consolelog/lightweight-mysql-migrate-tools :source-link: {git-url}/tree/master/mysql-migrate == 使用方法 === 引入jar包 [source,xml,subs="verbatim,attributes"] ---- cn.codeforfun mysql-migrate {version} ---- === 测试类 [source,java] ---- include::{testdir}/cn/codeforfun/migrate/core/MigrateTest.java[] ---- === 示例代码 example目录 image::https://gitee.com/consolelog/lightweight-mysql-migrate-tools/raw/master/demo.png[图片示例] == 实现原理 分别查询源数据库以及目标数据库链接下的 `information_schema` 数据库中的信息,根据信息解析成对应的表、函数等结构,再对比差异,拼接成SQL。 其中 : * {source-link}/src/main/resources/sql/detail/[src/main/resources/sql/detail] 目录下包含数据库表、函数等查询SQL * {source-link}/src/main/java/cn/codeforfun/migrate/core/Migrate.java[Migrate.java] 为核心类 * {source-link}/src/main/java/cn/codeforfun/migrate/core/Migrate.java[Migrate.java] 类中 https://gitee.com/consolelog/lightweight-mysql-migrate-tools/blob/master/mysql-migrate/src/main/java/cn/codeforfun/migrate/core/Migrate.java#L75[`compare()`] 方法为数据库表、函数等结构对比方法 * {source-link}/src/main/java/cn/codeforfun/migrate/core/entity/structure/Database.java[Database.java] 类中 https://gitee.com/consolelog/lightweight-mysql-migrate-tools/blob/master/mysql-migrate/src/main/java/cn/codeforfun/migrate/core/entity/structure/Database.java#L63[`configure()`] 为数据库表、函数等解析方法 include::CHANGELOG.adoc[] == 源码地址 * https://gitee.com/consolelog/lightweight-mysql-migrate-tools.git[Gitee源码] * https://github.com/qq253498229/lightweight-mysql-migrate-tools.git[Github源码] * https://consolelog.gitee.io/lightweight-mysql-migrate-tools/[GiteePages] * https://qq253498229.github.io/lightweight-mysql-migrate-tools/[GithubPages] == 反馈和贡献 * https://gitee.com/consolelog/lightweight-mysql-migrate-tools/issues[GiteeIssues] * https://github.com/qq253498229/lightweight-mysql-migrate-tools/issues[GithubIssues]