Sunday, January 29, 2012

Difference between mysqlcheck and myisamchk

Advertisements


Both mysqlcheck and myisamchk programs are used to check and repair tables. But there are some differences between them.

mysqlcheck :

1. Use to check, Repair and analyze myisam tables, innodb tables nad bdb tables.
2. mysqlcheck is a client program that communicates with the MySQL server over a network connection. You can run this from the server machine and from the remote machines.
3. for using mysqlcheck mysql service should be running.

myisamchk :

1. Use to check, Repair and analyze myisam tables. Can also disable or enable indexes.
2. Cannot be run from remote servers. This means that you must run myisamchk on the server host where those tables files are located. Also you need read permissions for checking operations and write permissions for repair operations.
3. Doesnt need the mysql service to be running. In fact if the service is running there is a chance for damaging files. SO its better shut down the mysql service if we are running myisamchk command.

Examples:

mysqlcheck:

For checking:
mysqlcheck database_name
mysqlcheck database_name  table_name1 table_name2
mysqlcheck --all-databases

For repairing:
mysqlcheck -r database_name
mysqlcheck -r database_name  table_name1 table_name2
mysqlcheck -r --all-databases

myisamchk:

Shutdown the service
change directory to the files are located eg: #cd /var/lib/mysql/database_name

For checking:
myisamchk table_name
myisamchk table_name.MYI

For repairing:
myisamchk -r table_name
myisamchk -r table_name.MYI

No comments:

Post a Comment

Be nice. That's all.