Scrivio Interview library
ScenarioAdvanced6 min read · updated 12 November 2026

You must migrate a 3 TB MySQL 5.7 database (end of life) to either MySQL 8.4 or PostgreSQL 17 with less than 10 minutes of downtime. How do you choose and plan each path?

Both paths keep the old database serving traffic while a new one is built and kept in sync, and both end with a short write freeze and a switch. The MySQL 8.4 path upgrades through replicas, 5.7 to 8.0 to 8.4, after fixing reserved words, the utf8mb4 default and authentication changes. The PostgreSQL 17 path converts the schema, copies the data, streams changes with CDC such as Debezium or a cloud migration service, and changes application queries. Both need validation with counts, checksums, shadow reads and production-like load, and a rollback route; we pick PostgreSQL only if its benefits justify a much larger project.

Why this question is asked

MySQL 5.7 reached end of life in October 2023, so running it means no security fixes. A 3 TB database cannot be dumped and restored inside a ten-minute window, so the migration has to happen while the old system keeps serving traffic, and the downtime is only the final switch. Interviewers ask this as a scenario because it tests planning: knowing the technical steps, seeing the risks, and making a reasoned choice between an upgrade and a platform change. In this answer, we will see why replication is the core of both paths, plan the MySQL 8.4 path and the PostgreSQL 17 path, define validation and cutover, and decide between them.

1Why Replication Is the Heart of Both Plans

Copying 3 TB takes many hours even on fast hardware, and rebuilding indexes on the target takes more. If we stop writes for the whole copy, we are down for a day. Instead, we copy a consistent snapshot while the old database runs, then continuously apply every change made since the snapshot, so the new database stays a few seconds behind. When we are ready, we stop writes briefly, let the last changes arrive, and switch. The downtime is that final step, which we can rehearse until it reliably takes a few minutes.

2The MySQL 8.4 Path: Upgrade Through Replicas

MySQL supports replication from a source to a replica one release series newer, but not upgrades that skip a series, so 5.7 cannot go straight to 8.4. We build an 8.0 replica of the 5.7 primary, then an 8.4 replica of that 8.0 server, forming a chain. Before that, MySQL Shell's upgrade checker reports most problems on the old server.

Java
mysqlsh admin@db57 -- util check-for-server-upgrade --target-version=8.0.40
-- Errors: 1 table 'app.window' uses reserved keyword 'window' (quote it or rename)
-- Warnings: 214 columns use utf8mb3; the new default is utf8mb4
-- Warnings: 6 users use mysql_native_password

The usual findings are words that became reserved in 8.0, such as RANK, GROUPS and WINDOW; the default character set changing to utf8mb4 with collation utf8mb4_0900_ai_ci, which changes comparisons and index sizes; and authentication: caching_sha2_password is the default, and in 8.4 mysql_native_password is no longer enabled by default, so old drivers and tools must be updated. Removed features such as the query cache, and GROUP BY no longer sorting implicitly, need a quick check of the application. Then we run the application's test suite and a replay of production queries against the 8.4 replica, and fail over to it.

3The PostgreSQL 17 Path: Convert, Copy and Stream

Moving engines is a different project. The schema must be converted: AUTO_INCREMENT becomes GENERATED ... AS IDENTITY, TINYINT(1) becomes boolean, unsigned integers need a wider type or a check constraint, ENUM becomes a check constraint or an enum type, and zero dates like '0000-00-00' must be cleaned because PostgreSQL rejects them. Collation matters too: MySQL's default comparisons ignore case, PostgreSQL's do not, so queries such as WHERE email = ? can start returning nothing unless we normalise data or use a case-insensitive collation.

The data moves in two parts: an initial bulk load, then change data capture. A Debezium MySQL connector reads the 5.7 binlog in row format and streams every change, through Kafka, into PostgreSQL; managed cloud migration services do the same in one product. Meanwhile the application changes: backtick quoting, LIMIT offset syntax, ON DUPLICATE KEY UPDATE, native queries and any reliance on MySQL's lenient GROUP BY all need rewriting and testing.

The two paths compared
MySQL 8.4PostgreSQL 17
Sync mechanismnative replication chainbulk load + CDC (Debezium, cloud service)
Schema workreserved words, charset, authfull type and DDL conversion
Application worksmall: drivers, a few queriesnative SQL, collations, upserts, tests
Rollback routelimited: newer to older replicationreverse CDC back to MySQL
Typical durationweeksmonths

4Validation Before Anyone Switches

We do not trust the copy until we have checked it. Row counts per table are the first, cheap check. Checksums over primary key chunks compare the content: pt-table-checksum works between MySQL servers, and for PostgreSQL we compute the same hash over normalised values on both sides chunk by chunk. Shadow reads send a sample of real read traffic to both databases and compare results, which catches collation and type surprises that a checksum can miss. And a performance test replays production traffic against the target, because a query plan that was fast on MySQL can be slow on PostgreSQL, and 8.4's optimizer can also choose differently from 5.7's.

5The Cutover in Under Ten Minutes

The cutover is rehearsed in staging until it is routine, with a written runbook and a named person for every step.

Step throughCutover runbook
  1. Lower DNS or proxy TTLs in advancethe day before
  2. Set the old primary read-onlysuper_read_only = ON, writes stop
  3. Target fully caught up?
    YesContinueNoWait; abort if over 5 minutes
  4. Run final counts and checksumson the hottest tables
  5. Switch connection stringsproxy or config, restart pools
  6. Open writes on the targetwatch errors and latency
  7. Start reverse replicationrollback route for a set period

7 steps in order. Play them, or step through them one at a time.

Keeping a rollback route is what makes the switch safe to attempt. For PostgreSQL, reverse CDC from PostgreSQL back to MySQL keeps the old system current for a few days. For MySQL, replication from a newer server to an older one is limited, so we check the compatibility rules for the exact versions and rehearse the rollback itself rather than assuming it works.

6Choosing Between the Paths

The MySQL path is the default because it solves the actual problem, an unsupported version, with the smallest change. The PostgreSQL path can be worth it when there is a real business or strategic reason: features we need such as partial indexes, jsonb with GIN or PostGIS, a company-wide decision to standardise on PostgreSQL, or licensing and support concerns. Then we present it honestly as a larger project with more application changes, a longer timeline and more risk. A common compromise is to do the 8.4 upgrade now, which removes the end-of-life risk in weeks, and plan any engine change separately.

7Follow-up questions

Why not upgrade the existing 5.7 server in place?

An in-place upgrade needs the server down for the duration and has no simple way back if the application misbehaves on 8.0. Building replicas lets us test the new version with real data for days while the old one serves traffic, and the switch is a failover we can rehearse.

How do we handle schema changes during a long migration?

We freeze or tightly control them. Every schema change must be applied to both sides in a compatible way, and CDC pipelines may break on DDL they do not understand, so changes go through one reviewed process during the migration.

What is the biggest hidden risk on the PostgreSQL path?

Behaviour differences that tests do not cover, especially case-insensitive comparisons, implicit type conversions and query plans under real load. Shadow reads and traffic replay are there to find them before customers do.

8Conclusion

In this answer, we saw that a 3 TB move with under ten minutes of downtime relies on keeping a new database in sync while the old one serves traffic. The MySQL 8.4 path chains replicas from 5.7 to 8.0 to 8.4 after fixing reserved words, utf8mb4 defaults and authentication. The PostgreSQL path converts the schema, bulk loads, streams changes with CDC and rewrites queries. Both validate with counts, checksums, shadow reads and traffic replay, and cut over with a short read-only window and a rollback route. We choose PostgreSQL only when its benefits justify a much larger project.

What to say in the interviewAbout 90 seconds aloud

Open with

With 3 TB and a ten-minute window, neither path can be a dump and restore. Both rely on building the new database alongside the old one, keeping it in sync, and making the final switch short.

Then, if they want more

For MySQL 8.4, I would run MySQL Shell's upgrade checker, fix reserved words, plan for utf8mb4 with utf8mb4_0900_ai_ci as the default and the authentication changes, since 8.4 no longer enables mysql_native_password by default.

Because you cannot skip a series, I would chain replicas: 5.7 primary to an 8.0 replica to an 8.4 replica, test the application against 8.4, then fail over.

For PostgreSQL 17, it is a bigger project: convert types and auto_increment to identity, handle zero dates and the case-sensitivity difference in collations, bulk load the data, then stream changes with CDC like Debezium or a cloud migration service, and rewrite MySQL-specific SQL.

For both, I would validate with row counts, chunked checksums, shadow reads comparing results, and a load test replaying production traffic. The cutover is rehearsed: set the old primary read-only, confirm the target has caught up, switch the connection strings, open writes, and keep reverse replication running for rollback.

My default choice is the 8.4 upgrade, because it fixes the end-of-life problem with the least risk; I would move to PostgreSQL only with a clear business or strategic reason.

About this answer

Last updated
12 November 2026
Versions it names
MySQL 8.4, PostgreSQL 17, MySQL 5.7
Checked
Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
Where the question comes from
Written by Scrivio for practice. It is not taken from an interview.
Official documentation
MySQL reference manual
Report an issue with this answer

Copy the line below and send it to the author with what you found. It carries the address of this page.

Issue with "You must migrate a 3 TB MySQL 5.7 database (end of life) to either MySQL 8.4 or...": https://scrivio-interview-library.netlify.app/databases/mysql/1f7c0f29d2/