Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mysql table repair failed: "Can't create new tempfile"

Tags:

mysql

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?

like image 408
James Zhao Avatar asked Jul 28 '15 18:07

James Zhao


3 Answers

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.

like image 98
James Zhao Avatar answered Nov 17 '22 06:11

James Zhao


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

like image 23
Gabriel Rodulfo Avatar answered Nov 17 '22 06:11

Gabriel Rodulfo


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.

like image 1
nilsree Avatar answered Nov 17 '22 07:11

nilsree