Categories
Uncategorized

“error : Wrong bytesec: 0-0-0 at linkstart: 0” at MyISAM

Sometimes you could not create Mysql dump because one or several tables corrupted. Then obviously it should be somehow restored. The Mysql and Maria have some standard tools for restoring crashed tables.

When creating a dump, Mysql says which MyISAM table is corrupted. So you can execute this to take the proof:

myisamchk /var/lib/mysql/data/dbname/tablename.MYI

Then you can restore it. But before that do not forget to create the backup:

cp /var/lib/mysql/data/dbname/tablename.MYI /var/lib/mysql/data/dbname/tablename.MYI-bak

By the way, to check all the MyISAM tables for errors, you can use the star mark:

myisamchk /var/lib/mysql/data/dbname/*.MYI

To restore the table, shutdown the mysql daemon and execute myisamchk with -r key:

myisamchk -r /var/lib/mysql/data/dbname/tablename.MYI

Then you can start the Mysql daemon and use the database as usual.

You can also use mysqlcheck command to check and repair table or the entire database:

# to check table
mysqlcheck -c -u root -p'password' -h mysqlhost dbname tablename
# to repair table
mysqlcheck -r -u root -p'password' -h mysqlhost dbname tablename
# to repair database
mysqlcheck -r -u root -p'password' -h mysqlhost dbname

As you can see, it uses a host, so mysqlcheck command needs the daemon to be running.

Leave a Reply

Your email address will not be published. Required fields are marked *