15

I run a WordPress website. Today I found that wp_posts table is crashed. When I tried to repair the table, I got the following error:

REPAIR TABLE wp_posts;

error Can't create new tempfile: './[databasename]/wp_posts.TMD' 

repair  status    Operation failed

I tried to run the following command in shell:

myisamchk -r -f wp_posts.MYI

error: File 'wp_posts.MYI' doesn't exist

Can you please tell me what else I can try to fix this problem?

Giacomo1968
  • 25,759
  • 11
  • 71
  • 103
James Zhao
  • 671
  • 1
  • 8
  • 17

6 Answers6

32

Turned out that "myisamchk -r -f wp_posts.MYI" was the correct solution. I just had to go to the data folder.

In my CentOS system, I changed directory to /var/lib/mysql/[database]/and found wp_posts.MYI

After removing this file, repair was successful.

Giacomo1968
  • 25,759
  • 11
  • 71
  • 103
James Zhao
  • 671
  • 1
  • 8
  • 17
23

Try stopping your service using the following command sudo service mysql stop

Now do the repair check myisamchk -r -f -o /var/lib/mysql/DatabaseName/wp_posts

Start your service and enjoy it!

It works for me

Gabriel Rodulfo
  • 231
  • 2
  • 2
  • This is magic. Thank you s much! You saved me. I tried. `sudo myisamchk -r -f -o /var/lib/mysql/[dbname]/wp_options` – Jed May 19 '20 at 10:10
1

Try adding the following line to your wp-config.php file:

define( 'WP_ALLOW_REPAIR', true );

Then go to: /wp-admin/maint/repair.php

That should take effect and automatically repair your crashed table.

nilsree
  • 302
  • 1
  • 7
1

I just had the same trouble. The problem was the .TMD file already existed and mysqlrepair refused to overwrite it. I removed the .TMD file and the mysqlrepair worked famously. I had to stop the process attempting to use the crashed table, then run the repair.

0

For mariaDB and some other combination of OS and DB version, the file may also be located under /config/databases/[DATABASE].
Try to run as root (sudo su):

service mysql stop
myisamchk -rf /config/databases/[databasename]/wp_posts.MYI
service mysql start
Slavik Meltser
  • 9,712
  • 3
  • 47
  • 48
0

When I saw this error in phpMyadmin, I got around it by navigating to /var/lib/mysql/[database]/ and deleting the TMD file for the table I was trying to repair (not the MYI file as stated in the explanation above).

When I tried getting rid of the MYI file, the repair operation didn't work.