To fulfill the repair or database optimization will be required mysqlcheck utility
To repair all databases:
mysqlcheck -Ar -u user -p pass
To optimize all databases:
mysqlcheck -Ao -u user -p pass
To repair and optimize all databases:
mysqlcheck -Aor -u user -p pass