6

i have this error when run repair?

myisamchk: error: 140 when opening MyISAM-table '/var/lib/mysql/zibarsho_karno/wp_yoast_seo_links.MYI'

how i can fix this ???

2

5 Answers 5

12
ls *.MYI | sed 's/\.[^.]*$//' | xargs myisamchk -F -U

Saved me here because of basename extra operand and other issue. Please note -F -U are for Fast and UPDATE STATUS flag. You can use without it.

1
  • upvoted because you can do this from the base directory, starting from ls * / *.MYI
    – iateadonut
    Feb 13, 2020 at 13:36
8

This is a bug already reported since MySQL 5.6

Still happening in 8.0.11 so in the mean time you can use the walkarround solution.

Not using the MYI extension.

myisamchk  --force --update-state var/lib/mysql/zibarsho_karno/wp_yoast_seo_links
1
  • And does still exist in 8.0.15 - reported 2017 as a bug and not fixed yet. Mar 5, 2019 at 12:24
7

As user Jesus Uzcanga already mentioned, it is an old bug which hasn't been fixed yet [current version is 8.0.15].

These commands are a workaround when you run it directly in the directory where the .MYI files are located:

ls *.MYI | xargs basename -s .MYI | xargs myisamchk

It removes the extension and runs myisamchk for each MyISAM data file.

2
  • Nice answer. I didn't know xargs. This seems to be a powerful command/program.
    – Carsten
    Mar 6, 2019 at 10:10
  • Adding -r to the myisamchk command here would also repair the damaged tables. Jul 9, 2019 at 3:52
2

try use this :

find /var/lib/mysql/*/* -name '*.MYI' | sed -e 's/\.MYI$//' | xargs -I{} myisamchk -r -f -o {}
0
ls *.MYI | xargs basename -s .MYI | xargs -I{} myisamchk -r --force {}
2
  • 3
    Please share some explanation for that code such that others can learn from it
    – Nico Haase
    May 16, 2019 at 8:26
  • ls lists files. xargs takes a list of files, and runs a command. basename -s is designed to specify a suffix to remove. xargs typically (e.g., when -L 1 is not used) puts as many list items on the command line was what will fit, so everything before the secnd pipe ends up making a second list. That list gets fed to another xargs. -I {} specifies that will be used as a filename, so that instead of placing a filename at the end of a command line, youc an place it where you want it. (There isn't much point to using -I {} early on, and then ending with {}.) Multiple tables will be myisamchk'ed
    – TOOGAM
    Feb 8 at 2:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.