MySQL table is marked as crashed and last (automatic?) repair failed
Asked Answered
C

12

161

I was repairing this table suddenly server hanged and when I returned back all tables are ok but this one showing 'in use' and when I try to repair it doesn't proceed.

ERROR 144 - Table './extas_d47727/xzclf_ads' is marked as crashed and last (automatic?) repair failed

What can I do to repair it?

Croat answered 12/1, 2012 at 23:16 Comment(2)
I've seen this mostly happen when the underlying file system goes out of free inodes. Check with df -hi. Usually something is filling it with loads of small files, like e.g. php session files that don't get cleaned up.Tatter
This discussion is probably aimed at MyISAM tables only.Wessels
T
315

If your MySQL process is running, stop it. On Debian:

sudo service mysql stop

Go to your data folder. On Debian:

cd /var/lib/mysql/$DATABASE_NAME

Try running:

myisamchk -r $TABLE_NAME

If that doesn't work, you can try:

myisamchk -r -v -f $TABLE_NAME

You can start your MySQL server again. On Debian:

sudo service mysql start
Thigpen answered 12/1, 2012 at 23:22 Comment(5)
I've got a myisam_sort_buffer_size is too small error, so this command worked for me: myisamchk -r -v --sort_buffer_size=2G <table_name>Gobo
My disk filled up while doing this, so it failed. After clearing space and trying it again, I was told it couldn't create "table_file_name.TMD". I guessed that it was because it already existed from when it failed before. After removing that file, it worked.Sandalwood
This solved my problem as well thank you. Using the --force option is what allows the repair to run even if something with the stucture or information is incorrect.Mockery
I ran into the error myisamchk: error: Not enough memory for blob at 541031156 (need 1953787962). The command myisamchk --max-record-length=1048576 -r -v -f $TABLE_NAME helped. I also created a backup copy of the file first; maybe a good general precaution.Sholapur
I'm getting similar type but not for single table, mysql crashed after few seconds of started. Would anybody can help to solve this issue. I've followed some solutions but unfortunately replaced by backup folder.Salesperson
J
136

Try running the following query:

repair table <table_name>;

I had the same issue and it solved me the problem.

Jacquejacquelin answered 11/9, 2014 at 1:2 Comment(1)
This was a quick fix! Had a "bad" options table. Make sure that you select the correct database first !Muezzin
B
54

This was my experience resolving this issue. I'm using XAMPP. I was getting the error below

 Fatal error: Can't open and lock privilege tables: Table '.\mysql\db' is marked as crashed and last (automatic?) repair failed  

This is what I did to resolve it, step by step:

  1. went to location C:\xampp\mysql, For you, location may be different, make sure you are in right file location.
  2. created backup of the data folder as data-old.
  3. copied folder "mysql" from C:\xampp\mysql\backup
  4. pasted it inside C:\xampp\mysql\data\ replacing the old mysql folder.

And it worked. Keep in mind, I have already tried around 10 solutions and they didnt work for me. This solutions may or may not work for you but regardless, make backup of your data folder before you do anything.

Note: I would always opt to resolve this with repair command but in my case, i wasnt able to get mysql started at all and i wasnt able to get myisamchk command to work.

Regardless of what you do, create a periodic backup of your database.

Bascomb answered 12/2, 2021 at 14:10 Comment(5)
One small comment, taking this solution that worked for me too may require you yo redefine MySQL password. From XAMPP UI open "shell" and use the command # mysqladmin -u root password Type the password you previously used and confirm password. Not it works again.Ericson
top answer, worked out smooth without any errorsStrict
none of the solutions worked for me. only this solution worked. its weird cause other people said the same thing...Shouse
This si the only solution worked for me.Katusha
Yeap that's the one Key is to always check mysql log file last few lines for error and you'll get answer within one minute :DAllotment
D
16

If it gives you permission denial while moving to /var/lib/mysql then use the following solution

$ cd /var/lib/
$ sudo -u mysql myisamchk -r -v -f mysql/<DB_NAME>/<TABLE_NAME>
Disruption answered 8/11, 2013 at 7:33 Comment(1)
Perfect, I was getting the permissions error. This sorted it.Tansey
R
10

I needed to add USE_FRM to the repair statement to make it work.

REPAIR TABLE <table_name> USE_FRM;
Rufe answered 10/5, 2017 at 13:13 Comment(0)
A
4

I got myisamchk: error: myisam_sort_buffer_size is too small as error.

The solution

myisamchk -r -v mysql/<DB_NAME>/<TABLE_NAME> --sort_buffer_size=2G
Abranchiate answered 26/2, 2015 at 7:33 Comment(0)
F
3

Go to data_dir and remove the Your_table.TMP file after repairing <Your_table> table.

Frohman answered 2/1, 2015 at 14:26 Comment(1)
search for it with this command grep -r datadir /etc/mysql/. Should be /var/lib/mysql under debian and ubuntu.Abranchiate
V
3

If this happend to your XAMPP installation, just copy global_priv.MAD and global_priv.MAI files from ./xampp/mysql/backup/mysql/ to ./xampp/mysql/data/mysql/.

Vantassel answered 24/1, 2021 at 14:56 Comment(1)
's solution worked for me, only in my case the table was ./mysql/db. I tried running myisamchk, but if pass 'db' as table name, it says 'file not found', if a specify the extension, i get "...is not a db file"Nath
E
2

This is a 100% solution. I tried it myself.

myisamchk -r -v -f --sort_buffer_size=128M --key_buffer_size=128M /var/lib/mysql/databasename/tabloname

Ecclesiastical answered 19/6, 2019 at 12:32 Comment(0)
T
2

Without stopping the database I go to this folder

cd /var/lib/mysql/$DATABASE_NAME

and then execute the following command

myisamchk -r -v -f $TABLE_NAME

enter image description here

Without having any issue the command successfully completed and resolve the issue

Thank you

Tala answered 28/10, 2021 at 5:22 Comment(3)
Please don't add "thank you" as an answer. Instead, vote up the answers that you find helpful. - From ReviewGingerich
This really works for the crash table situation, the only note I would like to add - replace $TABLE_NAME by your table file name (without extension).Cachepot
Please don’t post images of code, error messages, or other textual data.Puss
S
1

enter to your mysql and select your database then

repair table ;

this work with me

Sardou answered 30/8, 2022 at 16:5 Comment(0)
O
0

I tried the options in the existing answers, mainly the one marked correct which did not work in my scenario. However, what did work was using phpMyAdmin. Select the database and then select the table, from the bottom drop down menu select "Repair table".

  • Server type: MySQL
  • Server version: 5.7.23 - MySQL Community Server (GPL)
  • phpMyAdmin: Version information: 4.7.7
Oodles answered 21/10, 2018 at 12:41 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.