Convertir toutes les tables MyISAM en InnoDB

Pour toutes les tables de toutes les bases

“Version” séquentiel

la convertion de la table suivante sera faite que si la precedente est fini (ingnorer les erreurs pour les tables deja en  InnoDB 😉 )

#!/usr/bin/env bash
for db in `mysql --batch --skip-column-names -e "show databases;" | egrep -v "mysql|information_schema|performance_schema|lost"`; do
	echo "# "$db
	for table in `echo "show tables" | mysql --batch --skip-column-names $db`; do
		echo "-- "$table
		mysql $db -e "ALTER TABLE $table ENGINE = InnoDB;"
	done
done

“ Version ” Bourine

#!/usr/bin/env bash
for db in `mysql --batch --skip-column-names -e "show databases;" | egrep -v "mysql|information_schema|performance_schema|lost"`; do
	echo "# "$db
	for table in `echo "show tables" | mysql --batch --skip-column-names $db`; do
		echo "-- "$table
		mysql $db -e "ALTER TABLE $table ENGINE = InnoDB;" &
	done
done

Pour toutes les tables d’une base

Vous pouvez le faire de manière soft (Table par table)

#!/bin/bash
DATABASENAME="votrebdd"

for i in `echo "show tables" | mysql --batch --skip-column-names $DATABASENAME`; do
mysql $DATABASENAME -e "ALTER TABLE `$i` ENGINE = InnoDB;"
done

Ou en version “Multithread” (Bourine)

#!/bin/bash
DATABASENAME="votrebdd"

for i in `echo "show tables" | mysql --batch --skip-column-names $DATABASENAME`; do
mysql $DATABASENAME -e "ALTER TABLE `$i` ENGINE = InnoDB;" &
done


comments powered by Disqus