How to Migrate from SQLServer to MySQL

Galaxy Glossary

How do I migrate from SQL Server to MySQL without downtime?

Move schema and data from Microsoft SQL Server to MySQL with minimal downtime.

Sign up for the latest in SQL knowledge from the Galaxy Team!

Description

Why move from SQL Server to MySQL?

Cut licensing costs, adopt open-source tooling, and align with cloud-native stacks are the top drivers. MySQL’s wide hosting support and vibrant community make it attractive for fast-growing SaaS teams.

What prerequisites must be in place?

Prepare admin access to both servers, network connectivity, enough disk for export files, and a maintenance window if doing a cut-over.Install MySQL Workbench or MySQL Shell 8.0+ for migration tooling.

How do you export the SQL Server schema?

Generate a .sql script via SSMS “Tasks ➜ Generate Scripts”. Exclude “Set ANSI_PADDING” lines and choose “Schema only”. Save per-table files for easier type fixes.

Which SQL Server data types require manual mapping?

NVARCHARVARCHAR/TEXT, DATETIMEDATETIME(6), MONEYDECIMAL(19,4), BITTINYINT(1), and UNIQUEIDENTIFIERCHAR(36).Adjust PKs and indexes accordingly.

How do you load the converted schema into MySQL?

Point MySQL Workbench “Migration ➜ Run Target” to the edited script or run mysql -u root -p ecommerce < schema_mysql.sql. Fix errors iteratively.

How do you transfer data efficiently?

Option 1 – CSV + LOAD DATA

Use bcp to export each table as CSV, then LOAD DATA LOCAL INFILE in MySQL.Suitable for terabyte-scale since it is bulk-insert optimized.

Option 2 – MySQL Workbench Migration Wizard

The wizard connects to SQL Server via ODBC and streams data directly. Click-through UI is simpler but slower on large sets.

Option 3 – MySQL Shell “dumpInstance”

Install the MySQL Shell plugin mysqlsh util to produce parallelized dumps, then loadDump into MySQL 8.0.

How do you keep data in sync until cut-over?

Create SQL Server triggers that push incremental changes to staging tables, then schedule nightly exports.At cut-over, run a final delta script before switching application connection strings.

How can you validate a successful migration?

Run row-counts (SELECT COUNT(*)) on each table, compare MD5 checksums, and execute core business queries (e.g., daily revenue) against both databases for parity.

What best practices avoid downtime?

Enable foreign-key checks off during bulk load, disable MySQL binlog if replication not needed, and batch inserts in 10 k rows.Always stage in a test environment first.

How do you revert if something goes wrong?

Keep SQL Server read-only during cut-over so rollback is simply repointing the application. Retain CSV dumps and MySQL backups for quick restore.

.

Why How to Migrate from SQLServer to MySQL is important

How to Migrate from SQLServer to MySQL Example Usage


/* Validate order totals after migration */
SELECT o.id,
       c.name AS customer_name,
       o.total_amount,
       SUM(oi.quantity * p.price) AS computed_total
FROM   Orders o
JOIN   Customers c  ON c.id = o.customer_id
JOIN   OrderItems oi ON oi.order_id = o.id
JOIN   Products p ON p.id = oi.product_id
GROUP  BY o.id, c.name, o.total_amount
HAVING ABS(o.total_amount - computed_total) < 0.01;

How to Migrate from SQLServer to MySQL Syntax


-- Export data from SQL Server to CSV
bcp dbo.Customers out customers.csv -c -t , -S localhost -d ecommerce -U sa -P ******

-- MySQL: disable FK checks for faster load
SET FOREIGN_KEY_CHECKS = 0;

-- Load CSV into MySQL Customers table
LOAD DATA LOCAL INFILE 'customers.csv'
INTO TABLE Customers
FIELDS TERMINATED BY ',' ENCLOSED BY '"'
LINES TERMINATED BY '\n'
(id, name, email, created_at);

-- Re-enable FK checks
SET FOREIGN_KEY_CHECKS = 1;

Common Mistakes

Frequently Asked Questions (FAQs)

Is there an automated tool for full migration?

Yes. MySQL Workbench Migration Wizard migrates schema and data via ODBC. It is ideal for small to mid-size databases (<50 GB).

Can I keep identity columns?

Convert SQL Server IDENTITY to MySQL AUTO_INCREMENT. Ensure inserts exclude the column or set session variable sql_mode='NO_AUTO_VALUE_ON_ZERO' for zero-based IDs.

How do I migrate SQL Server stored procedures?

No one-click conversion exists. Rewrite in MySQL’s SQL/PSM or move logic to application code. Use Workbench to import bodies for manual editing.

Want to learn about other SQL terms?

Trusted by top engineers on high-velocity teams
Aryeo Logo
Assort Health
Curri
Rubie
BauHealth Logo
Truvideo Logo