How to check and Repair MySQL tables Using mysqlcheck command on Linux
January 01 2015
We have already discussed about mysqladmin command on previous post, on this post describe mysqlcheck. Mysqlcheck command is helpful to repair table and retrieve data when its corrupted also maintenance tables: check optimizes and analyzes.
Analyze the tables:
# mysqlcheck --analyze --databases mydb_linuxfaq
mydb_linuxfaq.idno OK
mydb_linuxfaq.testpa Table is already up to date
mydb_linuxfaq.mylist OK
mydb_linuxfaq.times OK
Check the tables status:
For example check the mysql database status whether is correpted,
# mysqlcheck mydb_linuxfaq
mydb_linuxfaq.idno OK
mydb_linuxfaq.idname OK
mydb_linuxfaq.mylist OK
mydb_linuxfaq.mode OK
mydb_linuxfaq.sqlapp OK
mydb_linuxfaq.questions OK
mydb_linuxfaq.rruns OK
mydb_linuxfaq.scoll OK
mydb_linuxfaq.tag OK
mydb_linuxfaq.tags OK
or
# mysqlcheck --databases mydb_linuxfaq
Check the tables for errors:
# mysqlcheck --check --databases mydb_linuxfaq
mydb_linuxfaq.userdetails OK
mydb_linuxfaq.image OK
mydb_linuxfaq.testimg OK
Error : Incorrect information in file: './mydb_linuxfaq/testfile.frm'
error : Corrupt
Repair Tables:
--auto-repir or --repair options is help to repair the tables which is correcpted, automatically fix it.
# mysqlcheck --auto-repair --databases mydb_linuxfaq
mydb_linuxfaq.diggotno OK
mydb_linuxfaq.idno OK
--repair or -r options is perform a repir that can fix anything,
# mysqlcheck --repair --databases db_name
The below command repir all the database in MySQL
# mysqlcheck --repair --all-databases
Check the tables for errors
# mysqlcheck --check --databases mydb_linuxfaq
Process all tables in the named databases
# mysqlcheck --databases mydb_linuxfaq
mydb_linuxfaq.usercomments OK
mydb_linuxfaq.cmdfilder OK
Comments (0)