Help us understand the problem. What is going on with this article?

[WordPress][MySQL] WordPress の全テーブルのエンジンをすべて innodb に変更する

More than 1 year has passed since last update.

小ネタ。
wp-cli を使って WordPress の全エンジンを InnoDB に変える方法。
ちまちま ALTER TABLE 発行するのも疲れるので。
こんな感じのシェルスクリプト作って実行すればいいんでないかな。

modify-engine.sh
#!/bin/bash
WP_PATH=${1:-/var/www/html}
TABLES=$(wp --path=${WP_PATH} db tables --all-tables)
for TABLE in ${TABLES}; do
    echo "** ${TABLE} **"
    wp --path=${WP_PATH} db query "ALTER TABLE ${TABLE} ENGINE=innodb, ALGORITHM=COPY;"
done

現在のテーブルのエンジンが何かを調べたい場合も、wp-cli でできるよ。

$ wp db query "SELECT table_schema, table_name, engine FROM information_schema.tables WHERE table_schema='$(wp eval 'echo DB_NAME;')';"
+--------------+-----------------------------+--------+
| table_schema | table_name                  | engine |
+--------------+-----------------------------+--------+
| wordpress    | wp_commentmeta              | InnoDB |
| wordpress    | wp_comments                 | InnoDB |
| wordpress    | wp_links                    | InnoDB |
| wordpress    | wp_options                  | InnoDB |
| wordpress    | wp_postmeta                 | InnoDB |
| wordpress    | wp_posts                    | InnoDB |
| wordpress    | wp_term_relationships       | InnoDB |
| wordpress    | wp_term_taxonomy            | InnoDB |
| wordpress    | wp_termmeta                 | InnoDB |
| wordpress    | wp_terms                    | InnoDB |
| wordpress    | wp_usermeta                 | InnoDB |
| wordpress    | wp_users                    | InnoDB |
+--------------+-----------------------------+--------+
digitalcubeinc
デジタルキューブは AWS Partner Network (APN) アドバンスドテクノロジーパートナーです。
https://ja.amimoto-ami.com/
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした