MySQL : Commandes avancées
La plupart de ces commandes sont disponibles pour MySQL ou MariaDB.
Q='`' ; mysql --skip-column-names -Be "select concat('alter table ${Q}', table_schema,'${Q}.${Q}', table_name, '${Q} engine=innodb;')
from information_schema.tables where engine = 'MyISAM' and table_schema not in ('mysql')" | mysql
Cette commande nous sert à convertir toutes les tables MyISAM en InnoDB. Un use case parmis tant d'autres, une cluster Galera.
MariaDB [(none)]> SHOW (FULL) PROCESSLIST \G;
Permet de lister les process SQL tournant d'une manière “propre” (\G), on peut également aller plus loin en détail en ajoutant FULL
MariaDB [(none)]> KILL xxxx
Permet de kill le process MySQL xxxx (Attention, rollback de la transaction, peut également être long)
SELECT CEILING(Total_InnoDB_Bytes*1.6/POWER(1024,3)) RIBPS FROM (SELECT SUM(data_length+index_length) Total_InnoDB_Bytes FROM information_schema.tables WHERE engine='InnoDB') A;
→ Savoir la taille du moteur InnoDB