A Java-based CLI application for 1:1 migration of MS-SQL databases to MariaDB.
- Database Analysis: Automatic extraction of tables, columns, indexes, constraints
- Schema Generation: Automatic conversion of MS-SQL DDL to MariaDB DDL
- Data Type Mapping: Intelligent mapping of MS-SQL to MariaDB data types
- Data Migration: Efficient batch migration with configurable parallelism
- Resume Capability: Resume interrupted migrations
- Progress Tracking: H2-based migration progress tracking
- Feature Detection: Detection of views, stored procedures, triggers
- Java 17 or higher
- Maven 3.6+
- Access to MS-SQL source database
- Access to MariaDB target database
# Clone the project
git clone https://github.com/bertolucci66/MSSQL-to-MySQL.git
cd MSSQL-to-MySQL
# Build with Maven
mvn clean package
# The JAR will be located at:
# target/mssql-to-mariadb-migrator.jar- Copy the example configuration:
cp config/migration.properties.example config/migration.properties- Adjust the configuration to your environment:
# MS-SQL Source
mssql.host=localhost
mssql.port=1433
mssql.database=SourceDB
mssql.username=sa
mssql.password=YourPassword123
mssql.schema=dbo
# MariaDB Target
mariadb.host=localhost
mariadb.port=3306
mariadb.database=TargetDB
mariadb.username=root
mariadb.password=YourPassword123
mariadb.charset=utf8mb4
# Migration Settings
migration.batch.size=1000
migration.parallel.threads=4
migration.fetch.size=5000
# Output Directories
output.schema.directory=output/schema
output.logs.directory=output/logs
output.analysis.directory=output/analysisRuns analysis, schema generation and data migration in a single pass:
java -jar target/mssql-to-mariadb-migrator.jar full-migration \
-c config/migration.propertiesAnalyzes the MS-SQL database and exports metadata as JSON:
java -jar target/mssql-to-mariadb-migrator.jar analyze \
-c config/migration.properties \
-o output/analysis/db_analysis.json \
--check-featuresGenerates MariaDB DDL from the analysis:
java -jar target/mssql-to-mariadb-migrator.jar generate-schema \
-i output/analysis/db_analysis.json \
-o output/schema/mariadb_schema.sqlApply the generated schema to MariaDB:
mysql -u root -p TargetDB < output/schema/mariadb_schema.sqlMigrates data from MS-SQL to MariaDB:
java -jar target/mssql-to-mariadb-migrator.jar migrate-data \
-c config/migration.properties \
--batch-size 2000 \
--parallel 4java -jar target/mssql-to-mariadb-migrator.jar migrate-data \
-c config/migration.properties \
-t "Customers,Orders,OrderDetails"java -jar target/mssql-to-mariadb-migrator.jar resume \
-c config/migration.propertiesAnalyzes the MS-SQL database structure.
Options:
-c, --config <path>- Path to configuration file (required)-o, --output <path>- Output JSON file (default: output/analysis/db_analysis.json)--check-features- Also analyze views, stored procedures and triggers
Generates MariaDB DDL from analysis JSON.
Options:
-i, --input <path>- Input JSON file (required)-o, --output <path>- Output SQL file (default: output/schema/mariadb_schema.sql)-t, --tables <list>- Comma-separated list of tables
Migrates data from MS-SQL to MariaDB.
Options:
-c, --config <path>- Path to configuration file (required)-t, --tables <list>- Comma-separated list of tables--batch-size <size>- Batch size for inserts--parallel <threads>- Number of parallel threads
Runs the complete migration (Analysis → Schema → Data).
Options:
-c, --config <path>- Path to configuration file (required)--check-features- Also analyze views, stored procedures and triggers
Resumes an interrupted migration.
Options:
-c, --config <path>- Path to configuration file (required)
| MS-SQL | MariaDB | Notes |
|---|---|---|
| INT | INT | |
| BIGINT | BIGINT | |
| DECIMAL(p,s) | DECIMAL(p,s) | |
| MONEY | DECIMAL(19,4) | |
| DATETIME | DATETIME | |
| DATETIME2 | DATETIME(6) | Higher precision |
| VARCHAR(n) | VARCHAR(n) | |
| VARCHAR(MAX) | LONGTEXT | |
| NVARCHAR(n) | VARCHAR(n) utf8mb4 | Unicode |
| NVARCHAR(MAX) | LONGTEXT utf8mb4 | |
| VARBINARY(n) | VARBINARY(n) | |
| VARBINARY(MAX) | LONGBLOB | |
| UNIQUEIDENTIFIER | VARCHAR(36) | GUIDs |
| BIT | BOOLEAN | |
| IMAGE | LONGBLOB |
-
Batch Size: Adjust
migration.batch.size(default: 1000)- Smaller batches: Better for large BLOBs
- Larger batches: Better for small records
-
Fetch Size: Adjust
migration.fetch.size(default: 5000)- Higher values reduce database round trips
-
Parallelism: Use
migration.parallel.threads(default: 1)- Useful for many small tables
- Watch connection pool limits
- Views: Detected only, not automatically converted
- Stored Procedures: Detected only, not automatically converted
- Triggers: Detected only, not automatically converted
- Complex Constraints: Must be verified manually
- Computed Columns: Not supported
Logs are written to the following files:
output/logs/migration.log- All logs (DEBUG level)output/logs/migration-error.log- Errors only (ERROR level)
- Check firewall settings
- Increase connection timeout in the configuration
- Reduce
migration.fetch.size - Reduce
migration.batch.size - Increase Java heap:
java -Xmx2G -jar ...
- The generated schema includes
DROP TABLE IF EXISTS - Verify you have write permissions on the target database
- Check logs in
output/logs/ - Use Ctrl+C to abort
- Use
resumeto continue
src/main/java/com/migration/tool/
├── analyzer/ # Database analysis
├── cli/ # CLI commands
├── config/ # Configuration management
├── connection/ # Connection pooling
├── exception/ # Exception hierarchy
├── mapping/ # Data type mapping
├── migration/ # Data migration
├── progress/ # Progress tracking
├── schema/ # Schema generation
└── util/ # Utility functions
mvn testmvn clean packageThe resulting JAR is located at target/mssql-to-mariadb-migrator.jar.
Contributions are welcome! Please open an Issue or submit a Pull Request.
This project is licensed under the MIT License.