For most MySQL teams, ALTER TABLE ... ENGINE=InnoDB is the fastest path for converting MyISAM tables, while mysqldump is safer for large migrations, version moves, or messy legacy schemas. InnoDB is the default storage engine in modern MySQL because it supports transactions, crash recovery, row-level locking, and foreign keys [source: MySQL]. A DBA converting a 40 GB reporting database may finish small tables in minutes with ALTER TABLE, but may prefer mysqldump when a clean rebuild, character set change, or server upgrade is also planned.
TLDR: ALTER TABLE is best when the database stays on the same server and the team needs a direct storage engine switch. mysqldump is better when the migration needs a clean copy, a rollback path, or a move to another MySQL server. For example, a team with 300 MyISAM tables might convert 260 small tables with ALTER TABLE, then dump and reload the 40 largest tables during a weekend window. If a 120 GB table takes 90 minutes to rebuild, the safer choice may be a dump restore into a staging server first.
Why Convert MyISAM to InnoDB?
MyISAM is simple and old. It still appears in legacy CMS installs, archived applications, and databases that have been upgraded for years without a full review. It can be fast for read-heavy workloads, but it lacks features that most production systems now expect.
- InnoDB supports transactions, so failed changes can roll back.
- InnoDB uses row-level locking, while MyISAM relies on table-level locking.
- InnoDB recovers better after crashes, which cuts the risk of corrupt tables.
- InnoDB supports foreign keys, if the application needs relational checks.
- InnoDB handles concurrent writes better under busy application traffic.
Honestly, it feels like MyISAM always waits until peak traffic to remind a team why table locks are painful. A single write can block reads and writes on the same table. On a busy store, forum, or booking system, that can turn small updates into visible lag.
Option 1: Convert with ALTER TABLE
The direct method is simple:
ALTER TABLE table_name ENGINE=InnoDB;
This command rebuilds the table using the InnoDB engine. It is clean, readable, and easy to run table by table. For small and medium tables, it is usually the least annoying option.
A DBA can generate conversion statements with a query like this:
SELECT CONCAT('ALTER TABLE `', table_schema, '`.`', table_name, '` ENGINE=InnoDB;')
FROM information_schema.tables
WHERE engine = 'MyISAM'
AND table_schema NOT IN ('mysql', 'information_schema', 'performance_schema', 'sys');
The main benefit is speed of execution. The database stays where it is. No dump file is needed. No restore step is required. Application configuration does not change.
The downside is operational risk. Large tables may take time to rebuild. During that rebuild, locks may block application activity. The exact locking behavior depends on the MySQL version, table structure, and operation path. Even when online DDL is available, MyISAM-to-InnoDB conversion still requires a physical table rebuild.
Expect to waste time on disk space checks. MySQL often needs extra room for the rebuilt copy, indexes, and temporary files. A safe rule is to keep at least 1.5x to 2x the table size free before converting large tables.
When ALTER TABLE Works Best
- The table is small enough to rebuild during a maintenance window.
- The server has enough free disk space.
- The MySQL version is not changing.
- The schema is clean and does not need heavy editing.
- The team wants a quick conversion with minimal tooling.
Option 2: Convert with mysqldump
The dump-and-restore method exports the database or selected tables, changes the engine definitions, and imports the data again. A basic flow looks like this:
mysqldump --single-transaction --routines --triggers database_name > database.sql
Then the dump file can be edited so ENGINE=MyISAM becomes ENGINE=InnoDB. After that, it is restored into a new database or server:
mysql new_database < database.sql
There is one annoying detail. --single-transaction is great for InnoDB, but it does not give the same clean snapshot guarantee for MyISAM tables. For MyISAM-heavy databases, a read lock or downtime window may still be needed to get a consistent dump.
The main benefit is control. The migration can be tested on another server. Bad indexes can be reviewed. Character sets can be fixed. Old table options can be removed. The team can compare row counts before switching the application.
The downside is time. Dumping and restoring a large database can take longer than a direct table conversion. It also needs more storage because the SQL dump, restored database, and original data may all exist at once.
When mysqldump Works Best
- The migration is moving to a new server.
- The MySQL version is changing.
- The team wants a tested rollback option.
- The database has years of legacy schema clutter.
- The largest tables are too risky to rebuild in place.
Side-by-Side Comparison
| Factor | ALTER TABLE | mysqldump |
|---|---|---|
| Speed | Often faster for small tables | Slower due to export and import |
| Risk | Higher on large live tables | Lower if tested on staging first |
| Rollback | Requires backup restore | Old database can stay untouched |
| Best use | Same-server conversion | Server move or cleanup project |
Checks Before Any Conversion
Before storage engines are changed, the administrator should run a few checks. Skipping them is how a simple task becomes a 2 a.m. restore job.
- Take a full backup and test that it restores.
- Check free disk space on the data directory and temporary directory.
- Record row counts before and after migration.
- Review indexes, especially very large or old full-text indexes.
- Check application code for assumptions about table locks or repair commands.
- Confirm character sets and collations before rebuilding tables.
A useful precheck query is:
SELECT table_schema, table_name, engine, table_rows,
ROUND((data_length + index_length) / 1024 / 1024, 2) AS size_mb
FROM information_schema.tables
WHERE engine = 'MyISAM'
ORDER BY size_mb DESC;
This shows the tables that deserve the most planning. The largest 10% often cause 90% of the waiting, blocking, and stress.
Best Practical Strategy
The safest plan is usually mixed. Small tables can be converted with ALTER TABLE. Huge tables can be migrated through mysqldump, replication, or a staged restore. That keeps the quick wins easy and gives risky tables more care.
For a production system, the team should first test the exact process on a staging copy. It should measure conversion time, disk growth, application errors, and index rebuild speed. If a staging conversion of a 20 GB table takes 28 minutes, the production window should not be planned for 30 minutes. It should include buffer time, checks, and rollback steps.
FAQ
Is ALTER TABLE enough to convert MyISAM to InnoDB?
Yes. ALTER TABLE table_name ENGINE=InnoDB; converts a table directly. It is often the simplest method for same-server migrations.
Is mysqldump safer than ALTER TABLE?
It can be safer when the restore is tested on another server. The original database can remain unchanged until cutover.
Does converting to InnoDB cause downtime?
It may. Large table rebuilds can block traffic or slow the server. A maintenance window is still wise.
Should every MyISAM table become InnoDB?
Usually, yes for active applications. Rare archive tables or special read-only workflows may not need urgent conversion.
What should be checked after migration?
The administrator should compare row counts, run application tests, check error logs, review slow queries, and confirm that backups still work.