Skip to content

Converting MyISAM tables to InnoDB on a cPanel account without locking the site for an hour

MyISAM tables on a 2026 cPanel host are a liability — no crash safety, no foreign keys, table-level locking. Converting requires care on the bigger tables but is generally a few-minute job per database.

A cPanel account on an inherited host has a WordPress database where wp_options is InnoDB but wp_posts is MyISAM, because a plugin from 2017 ran ENGINE=MyISAM somewhere. The site mostly works. Then the host has a power blip, MariaDB starts up with one MyISAM table marked crashed, the site shows a database error, and mysqlcheck --repair runs for 40 minutes while you watch. MyISAM has not been the right choice for years; the fix is to convert the lingering tables to InnoDB and remove a class of incidents from your inbox.

What’s happening

MyISAM stores tables as separate index (.MYI) and data (.MYD) files. It has no crash safety — every unclean shutdown can leave a table marked as crashed, requiring REPAIR before reads work. It has no foreign keys, no row-level locking (the whole table locks on every INSERT or UPDATE), and the default since MySQL 5.5 has been InnoDB. The reasons MyISAM was chosen at the time (lower disk usage for read-heavy workloads, full-text search before InnoDB had it) no longer hold — InnoDB has full-text search since 5.6 and the storage difference is rarely material.

Conversion is a table rebuild: ALTER TABLE foo ENGINE=InnoDB reads every row from the MyISAM file and writes it to a new InnoDB file. During the rebuild, the original table is locked for write (and on older versions, also for read). On a 5GB table that’s a 10–30 minute operation.

How to verify

mysql -e "SELECT TABLE_SCHEMA, TABLE_NAME, ENGINE, TABLE_ROWS, ROUND(DATA_LENGTH/1024/1024) AS data_mb FROM information_schema.TABLES WHERE ENGINE='MyISAM' AND TABLE_SCHEMA NOT IN ('mysql','information_schema','performance_schema','sys') ORDER BY DATA_LENGTH DESC"
mysql -e "SHOW VARIABLES LIKE 'default_storage_engine'"
mysql -e "SELECT ENGINE, SUPPORT FROM information_schema.ENGINES WHERE ENGINE='InnoDB'"

The first query lists every MyISAM table, sorted by size. The second confirms the server default (should be InnoDB; if it’s still MyISAM, fix that too in /etc/my.cnf.d/cpanel.cnf). The third confirms InnoDB is enabled and the default storage engine is available.

The fix

  1. Convert small tables first to catch any constraint surprises. A 100-row table converts in milliseconds:
    mysql -e "ALTER TABLE acmecorp_wp.wp_users ENGINE=InnoDB"
  2. Generate the conversion statements for every remaining MyISAM table:
    mysql -N -e "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')" > /tmp/convert.sql
  3. Run the conversion during a maintenance window if any individual table is over a few hundred MB. For a busy WordPress site, write traffic during conversion will queue up — pick a low-traffic hour:
    mysql < /tmp/convert.sql
  4. For very large tables, use pt-online-schema-change from Percona Toolkit. It creates a shadow InnoDB copy, triggers data forward, swaps the table atomically. No locking window:
    pt-online-schema-change --alter "ENGINE=InnoDB" D=acmecorp_wp,t=wp_posts --execute
  5. Set the default storage engine to InnoDB in /etc/my.cnf.d/cpanel.cnf so new tables created by apps default correctly:
    [mysqld]
    default_storage_engine = InnoDB
  6. Watch for full-text index issues: MyISAM full-text uses different stop words and minimum word length than InnoDB. If an app uses MATCH ... AGAINST and converts the table, search may return fewer results. Re-tune innodb_ft_min_token_size if needed.
  7. Verify after conversion:
    mysql -e "SELECT COUNT(*) FROM information_schema.TABLES WHERE ENGINE='MyISAM' AND TABLE_SCHEMA NOT IN ('mysql','information_schema','performance_schema','sys')"
    Should be zero (or only the few that genuinely need MyISAM, which is none for typical web apps).
  8. Update backups: a MyISAM-aware backup script might use FLUSH TABLES WITH READ LOCK; once everything is InnoDB, switch to --single-transaction and the lock window disappears.

For takeover hosts where MyISAM lingers across many accounts, Stack Harbor’s managed cPanel operations team scripts the conversion per account with online schema change for the big tables and a verification pass at the end.