How to Migrate from MariaDB to Redshift in PostgreSQL

Galaxy Glossary

How do I migrate data from MariaDB to Amazon Redshift?

Move data from MariaDB to Amazon Redshift by exporting, staging in S3, and loading with Redshift’s PostgreSQL-compatible COPY command.

Sign up for the latest in SQL knowledge from the Galaxy Team!
Welcome to the Galaxy, Guardian!
Oops! Something went wrong while submitting the form.

Description

Table of Contents

What is the fastest way to move MariaDB tables to Redshift?

Export each MariaDB table to CSV, upload the files to Amazon S3, then run Redshift’s COPY command. The process handles large datasets efficiently and preserves schema fidelity.

Which tools help automate the migration?

AWS Schema Conversion Tool (SCT) converts DDL, and AWS Database Migration Service (DMS) keeps MariaDB and Redshift in sync until cut-over. Use them when you need minimal downtime.

How do I export data from MariaDB?

Run mysqldump --tab or SELECT ... INTO OUTFILE per table. Compress outputs to reduce transfer time. Example:

mysqldump -u admin -p --tab=/tmp/ecom_dump \
--fields-terminated-by="," --fields-enclosed-by='"' \
--lines-terminated-by="\n" ecommerce Orders Products Customers OrderItems

How do I stage files in S3?

Use the AWS CLI. Keep each table in its own prefix for easier COPY commands:

aws s3 cp /tmp/ecom_dump s3://ecom-stage/ --recursive --exclude "*sql"

How do I create matching tables in Redshift?

Convert every MariaDB table to Redshift DDL. Example for Orders:

CREATE TABLE public.orders (
id INT IDENTITY(1,1) PRIMARY KEY,
customer_id INT NOT NULL,
order_date TIMESTAMP,
total_amount NUMERIC(12,2)
);

How do I load data into Redshift quickly?

Run one COPY per table. Use the DATEFORMAT and TIMEFORMAT options to match your CSV files.

COPY public.orders
FROM 's3://ecom-stage/Orders/'
IAM_ROLE 'arn:aws:iam::123456789012:role/RedshiftCopyRole'
FORMAT AS CSV
IGNOREHEADER 1
TIMEFORMAT 'auto'
COMPUPDATE OFF;

How do I validate the migration?

Row-count checks catch most issues. Example query:

-- Redshift
SELECT COUNT(*) AS redshift_rows FROM public.orders;
-- MariaDB
SELECT COUNT(*) AS mariadb_rows FROM Orders;

Can I keep both databases in sync until cut-over?

Yes. Configure AWS DMS in "full load + ongoing replication" mode. Choose CDC based on MariaDB binary logs to stream inserts, updates, and deletes.

What are best practices for large ecommerce datasets?

Compress CSV files with GZIP, split into 1–4 GB chunks, match Redshift distribution/sort keys to query patterns, and disable constraints until all data loads.

Why How to Migrate from MariaDB to Redshift in PostgreSQL is important

How to Migrate from MariaDB to Redshift in PostgreSQL Example Usage


-- Load OrderItems after all dimension tables
COPY public.orderitems
FROM 's3://ecom-stage/OrderItems/'
IAM_ROLE 'arn:aws:iam::123456789012:role/RedshiftCopyRole'
FORMAT AS CSV
IGNOREHEADER 1
TIMEFORMAT 'auto'
ACCEPTINVCHARS AS '^';

How to Migrate from MariaDB to Redshift in PostgreSQL Syntax


-- 1. Export from MariaDB (Linux shell)
mysqldump -u admin -p --tab=/tmp/ecom_dump \
  --fields-terminated-by="," \
  --fields-enclosed-by='"' \
  --lines-terminated-by="\n" \
  ecommerce Customers Orders Products OrderItems

-- 2. Upload to S3
aws s3 cp /tmp/ecom_dump s3://ecom-stage/ --recursive --exclude "*sql"

-- 3. Redshift DDL (PostgreSQL-compatible)
CREATE TABLE public.customers (
  id          INT IDENTITY(1,1) PRIMARY KEY,
  name        VARCHAR(255),
  email       VARCHAR(255),
  created_at  TIMESTAMP
);

-- 4. COPY syntax
COPY public.customers
FROM 's3://ecom-stage/Customers/'
IAM_ROLE 'arn:aws:iam::123456789012:role/RedshiftCopyRole'
FORMAT AS CSV
IGNOREHEADER 1
TIMEFORMAT 'auto'
COMPUPDATE OFF;

Common Mistakes

Frequently Asked Questions (FAQs)

Can I migrate without S3?

Redshift requires data in S3, DynamoDB, or EMR for COPY. Without S3 you must use INSERT, which is slow. Use temporary S3 buckets even for small loads.

Does Redshift support MariaDB data types?

Most common types map directly. Convert TEXT to VARCHAR(max), DECIMAL to NUMERIC, and TINYINT to SMALLINT.

How do I migrate incremental changes after the initial load?

Enable AWS DMS change data capture (CDC) to stream binlog events from MariaDB to Redshift continuously until you switch applications over.

Want to learn about other SQL terms?

Trusted by top engineers on high-velocity teams
Aryeo Logo
Assort Health
Curri
Rubie Logo
Bauhealth Logo
Truvideo Logo
Welcome to the Galaxy, Guardian!
Oops! Something went wrong while submitting the form.