---
title: "Do you need to convert your tables from InnoDB to MyISAM?"
description: "If your database grows in size for no apparent reason, or if it takes longer than usual to process any query, it is more than likely that you need to change your tables from InnoDB to MyISAM. Although the first"
url: https://artprojectgroup.com/do-you-need-to-convert-your-tables-from-innodb-to-myisam
date: 2015-09-15
modified: 2026-09-19
author: "Art Project Group"
image: https://artprojectgroup.com/wp-content/uploads/2023/02/wordpress-blog.webp
categories: ["Tutorials"]
tags: ["MySQL", "PHP", "phpMyAdmin", "WordPress"]
type: post
lang: en-US
---

# Do you need to convert your tables from InnoDB to MyISAM?

If your database grows in size for no apparent reason, or if it takes longer than usual to process any query, it is more than likely that you need to change your tables from InnoDB to MyISAM.

Although the first MySQL storage engine is more reliable, consistent and robust than the second, we have come across quite a few websites where it causes serious performance problems and excessive growth of the tables, especially in the *wp_options*, *wp_posts* and *wp_postmeta* tables.

We have detected these problems on websites hosted under Parallels Plesk Panel, cPanel and Vesta Control Panel, so it is independent of the type of control panel your server uses and even of the versions of MySQL, PHP or WordPress you have installed.

### How do we do it?

In principle we can do it in two ways.

First of all we can create a simple PHP file in the root directory of WordPress, which we will call cambia-tablas.php, for example, and in which we will include this simple, easy but effective PHP code:

Copy to clipboardSyntax Highlighterif ( file_exists( "./wp-load.php" ) ) {
require_once( "./wp-load.php" );
} else {
exit( '404 Not Found

# Not found

Please make sure that change-tables.php is in the root directory.' );
}

$query = $wpdb->get_results( "SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_SCHEMA = '" . DB_NAME . "'" );

foreach ( $query as $row ) {
$row_name = $row->TABLE_NAME;
$new_query = $wpdb->query( "ALTER TABLE `$row_name` ENGINE = MYISAM DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;" );
}
echo "Process finished in " . DB_NAME;

$query = $wpdb->get_results( "SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_SCHEMA = '" . DB_NAME . "'" );

foreach ( $query as $row ) {
$row_name = $row->TABLE_NAME;
$new_query = $wpdb->query( "ALTER TABLE `$row_name` ENGINE = MYISAM DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;" );
}
echo "Process finished in " . DB_NAME;
We can also do it by running this SQL query directly in our [phpMyAdmin](https://www.phpmyadmin.net/downloads/), [MySQL Workbench](https://dev.mysql.com/downloads/workbench/) or [MySQL Utilities](https://downloads.mysql.com/archives/utilities/), for example:

Copy to clipboardSyntax HighlighterSET @DATABASE_NAME = 'your_database_name';

SELECT CONCAT('ALTER TABLE `', table_name, '` ENGINE = MYISAM DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;') AS sql_statements
FROM information_schema.tables AS tb
WHERE table_schema = @DATABASE_NAME
AND `TABLE_TYPE` = 'BASE TABLE'
ORDER BY table_name DESC;

Where we only have to change *base_de_datos* for the name of our own database and the query will return a table with several ALTER statements, specifically a list similar to this one:

Copy to clipboardSyntax HighlighterALTER TABLE `wp_users` ENGINE = MYISAM DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
ALTER TABLE `wp_usermeta` ENGINE = MYISAM DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
ALTER TABLE `wp_term_taxonomy` ENGINE = MYISAM DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
ALTER TABLE `wp_term_relationships` ENGINE = MYISAM DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
ALTER TABLE `wp_terms` ENGINE = MYISAM DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
ALTER TABLE `wp_posts` ENGINE = MYISAM DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
ALTER TABLE `wp_postmeta` ENGINE = MYISAM DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
ALTER TABLE `wp_options` ENGINE = MYISAM DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
ALTER TABLE `wp_links` ENGINE = MYISAM DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
ALTER TABLE `wp_comments` ENGINE = MYISAM DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
ALTER TABLE `wp_commentmeta` ENGINE = MYISAM DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
Once we have the list of statements, we only have to copy them all and run them inside the database whose tables we want to convert from InnoDB to MyISAM.

> Note that as well as converting the tables to MyISAM we force the collation to UTF-8, specifically to utf8_general_ci, which will mean we get rid of strange characters in our database.

### Benefits

The benefits we have obtained by making these modifications have been two.

On the one hand we have managed to slim down databases that were several GB in size to a few hundred MB. The reason is that InnoDB tables do not allow optimization, and that sometimes makes them fill up with unnecessary records.

And on the other we have managed to reduce the processing times of some queries considerably, by up to 74%. Normally caused by that same excessive size of the tables. By removing that large amount of unnecessary records, we considerably reduce the processing times of those queries.

### Conclusion

If you are suffering from any of the problems described, try using this small trick on your database. If the problem persists, then you should leave your website in the hands of a WordPress specialist such as **APG**.
