COMANDO MYSQLCHECK: VERIFICANDO E CORRIGINDO DB MYSQL

Com o comando mysqlcheck podemos verificar se um determinado banco ou tabela de um banco está integro, sem erros ou corrompido. Mostrarei algumas de suas opções das diversas que existem.

  • Verificando uma determinada tabela

mysqlcheck -c nome_do_banco nome_da_tabela -u root -p
  • Verificando um banco inteiro

mysqlcheck -c nome_do_banco -u root -p

Em testes que precisei no banco de um zabbix server, tive o seguinte resultado abaixo, mostrando que “algo de errado não estava certo”, ou seja, com erros.
zabbixdb.group_prototype                           OK
zabbixdb.groups                                    OK
zabbixdb.history
warning  : Table is marked as crashed
warning  : 1 client is using or hasn't closed the table properly
error    : record delete-link-chain corrupted
error    : Corrupt
zabbixdb.history_log                               OK
zabbixdb.history_text                              OK
zabbixdb.history_uint
warning  : Table is marked as crashed
warning  : 1 client is using or hasn't closed the table properly
error    : record delete-link-chain corrupted
error    : Corrupt
zabbixdb.host_discovery                            OK
zabbixdb.host_inventory                            OK
  • Corrigindo erros de um banco

mysqlcheck -r nome_do_banco -u root -p

Obtive o seguinte resultado, corrigindo assim os erros que tive no banco:
zabbixdb.group_prototype                           OK
zabbixdb.groups                                    OK
zabbixdb.history
warning  : Number of rows changed from 5764036 to 5763139
status   : OK
zabbixdb.history_log                               OK
zabbixdb.history_text                              OK
zabbixdb.history_uint
warning  : Number of rows changed from 13583760 to 13633846
status   : OK
zabbixdb.host_discovery                            OK
zabbixdb.host_inventory                            OK

FONTES

MySQL: use o mysqlcheck para fazer manutenção das suas tabelas

Marcado com , ,