Move data from MariaDB to Amazon Redshift by exporting, staging in S3, and loading with Redshift’s PostgreSQL-compatible COPY command.
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.
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.
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
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"
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)
);
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;
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;
Yes. Configure AWS DMS in "full load + ongoing replication" mode. Choose CDC based on MariaDB binary logs to stream inserts, updates, and deletes.
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.
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.
Most common types map directly. Convert TEXT
to VARCHAR(max)
, DECIMAL
to NUMERIC
, and TINYINT
to SMALLINT
.
Enable AWS DMS change data capture (CDC) to stream binlog events from MariaDB to Redshift continuously until you switch applications over.