WordPressメモ


突然Wordpressの新しい記事が見えなくなってしまい、とりあえず再起動したら、すべての記事が見えなくなってしまったので、いろいろ調べてみたら、SQLの一部テーブルが壊れてしまったらしい。

原因に気づいたのは、試行錯誤の前にmysqlのDBバックアップをしようとしたら、テーブルが壊れている旨のメッセージが出たため。

mysqldump -u wordpress -p データベース名

ERROR 145: Table './zabbix/wp_posts' is marked as crashed and should be repaired


なので修復してみる(こんな感じ)

wordpress ~ # mysql -u wordpress -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 494
Server version: 5.1.67 Gentoo Linux mysql-5.1.67

Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> repair table wordpress.wp_posts;
+--------------------+--------+----------+----------+
| Table | Op | Msg_type | Msg_text |
+--------------------+--------+----------+----------+
| wordpress.wp_posts | repair | status | OK |
+--------------------+--------+----------+----------+
1 row in set (0.31 sec)

これで直った。

 

ついでにたまった記事のコメントのを削除

WordPressでSQLから承認待ちコメントを一括で削除する方法

DELETE FROM wordpress.wp_comments WHERE comment_approved=’0′;

データベース名がwordpressの場合、上記のように入力します。

実行例

login as: root
Using keyboard-interactive authentication.
Password:
Last login: Sun Jun 7 16:12:33 JST 2015 from qf970hg-pc.local on pts/0
wordpress ~ # mysql -u wordpress -p wordpress
Enter password:
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 281
Server version: 5.1.67 Gentoo Linux mysql-5.1.67

Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> DELETE FROM wordpress.wp_comments WHERE comment_approved='0';
Query OK, 15400 rows affected (0.56 sec)

Views: 10

カテゴリー: WordPress パーマリンク

コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です