LoginSignup
35
34

More than 5 years have passed since last update.

【WordPress】DBの文字コードをのエラーがでたときの対処法メモ

Last updated at Posted at 2015-08-07

ローカルのWordPressをテストサーバに移そうとしたら
Unknown collation: 'utf8mb4_unicode_ci'
ってエラーが出たので、対処法をメモ。
★エラー内容としては(サーバのバージョンが低いなどの理由で)utf8mb4が使えないよ(意訳)ってことらしい。

まずコマンドで文字コードを変換する

※MAMPの場合

cd /Applications/MAMP/Library/bin
./mysql -u root -p ;
// パスワードの入力

//1つ1つテーブルを変換
ALTER TABLE テーブルの名前 DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;

エクスポート

照合順序の「utf8mb4_general_ci」が「utf8_general_ci」に変わっていることを確認して、
エクスポート

SQLの修正

エクスポートしたSQLをテキストエディタで開いて、「utf8mb4」→「utf8」に置換
URL等も変更する

【重要】wp-config.phpを修正

define('DB_CHARSET', 'utf8mb4');

define('DB_CHARSET', 'utf8');
35
34
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
35
34