We use cookies
We use cookies to optimize our website. By continuing to browse the site, you agree to our use of cookies.
New design
Control panel
  • Русский
  • Українська
  • English
  • UAH
  • USD
  • RUB
  • EUR
  • 0-800-307-307 Hotline
  • +38 (044) 392-74-33 Kiev
  • +38 (057) 728-39-00 Kharkiv
  • +38 (056) 794-38-31 Dnipro
  • +38 (032) 229-58-93 Lviv
  • +38 (048) 738-57-70 Odessa
  • +38(093) 170-15-42  Life
  • +38 (067) 400-88-44 Kievstar
  • +1(888)393-24-51  USA, Toll free
  • +44(131)507-01-14  Great Britain
  • +7 (499) 348-28-61 Moscow

2.8.1.3. Converting storage of all tables

(Requirements: PHP 5+)

To convert all tables, you can run a script that will execute an SQL query for each individual table.

  1. <?php
  2. $DB = array(
  3. 'host' => 'example.mysql.tools',
  4. 'user' => 'example_db',
  5. 'password' => 'xxxxxxxxxx',
  6. 'database' => 'example_db',
  7. 'engine' => 'InnoDB'
  8. );
  9. $link = mysqli_connect($DB['host'], $DB['user'], $DB['password'], $DB['database']);
  10. $sql = "SHOW TABLES";
  11. $query = mysqli_query($link, $sql);
  12. while ($row = mysqli_fetch_assoc($query)) {
  13. if (mysqli_query($link, "ALTER TABLE `".$row['Tables_in_'.$DB['database']]."` ENGINE = ".$DB['engine'])) {
  14. echo $row['Tables_in_'.$DB['database']]." ok<br>";
  15. } else {
  16. echo $row['Tables_in_'.$DB['database']]." error<br>";
  17. }
  18. }

In the script you need to specify connection data to the database:

  1. host - database server.
  2. user - the name of the database user.
  3. password - database user password.
  4. database - the name of the database.
  5. engine - the target storage type to which all tables will be changed.

Alternative ways of changing the storage type are described here.