1

I'm trying to repair some corrupted tables throught mysqlcheck command, but it returns the following "errno 2" error:

# mysqlcheck -u user -p --repair database
Enter password:
database.users                                OK
database.notes
Error    : Can't find file: 'notes' (errno: 2)
status   : Operation failed
...

I don't even need the information that was stored in that tables I can't repair, if only I could repair the tables without information it would be fine.

Do you happen to know if is there any way to repair the corrupted tables?

AngeLOL
  • 106
  • 2
  • 9
  • Check this https://stackoverflow.com/questions/12106727/mysql-copying-tables-files-gives-rise-to-error-1017-hy000-cant-find-file. If this helps – Prabhjot Singh Kainth Nov 15 '19 at 05:45
  • Is it a `myisam`, `innodb` or what? `mysqlcheck` can not repair Unique Keys that aren't unique. First check your data for duplicated records in unique key column. If data is okay then you can try aquick fix with the data structure only (it will not touch the data file), doing like this: `myisamchk --quick ` – devasia2112 Nov 15 '19 at 05:53
  • @PrabhjotSinghKainth I found the database files, but their permisions were ok, I already tried with mysqcheck, but it didn't work – AngeLOL Nov 15 '19 at 06:27
  • 1
    @deepcell it is myisam, I wanted to try through myisamchk as you suggested, but the MYI files are missing – AngeLOL Nov 15 '19 at 06:50
  • this command should fix the table index for you > `REPAIR TABLE your_table USE_FRM;` – devasia2112 Nov 15 '19 at 09:09
  • @deepcell I already tried it, but the same error is displayed – AngeLOL Nov 15 '19 at 13:55
  • What do you see in your `/var/mysql/` dir? is there any .FRM or .MYD file? if there is nothing, then forget it's all gonna. restore backup if you have. – devasia2112 Nov 16 '19 at 04:53

1 Answers1

0

Worked for me:

Stop MySQL to free memory and get MySQL run memory parameter to put in the repair command:

myisamchk --sort_buffer_size=20M --key_buffer_size=5G --read_buffer_size=8M --write_buffer_size=8M -t DIR_WITH_SPACE -r PATH_TO_TABLE.MYI

DIR_WITH_SPACE has to store tmp file as big as MYI table file. If you don't specify it, it'll use the system tmp, beware of reaching full.

PATH_TO_TABLE.MYI is the MYI file of your table, in the MySQL data dir or elsewhere read/write place.

Then the mysqlcheck should be useless and table usable.

Leahkim
  • 343
  • 1
  • 2
  • 11