2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Dockerで起動したMySQLにデータimportしたら文字化けするので困った話

Posted at

結論

これで直った

$ docker compose exec db /bin/bash -c "mysql  --default-character-set=utf8 -uroot -p db_name < xxx.sql"

やったこと

ファイルの文字コード確認

$ nkf --guess xxx.sql
UTF-8 (LF)

UTF8でした

my.cnfで設定

show variables like '%char%';

これ実行すると character_set_serverlatin1 だったのでこれかな?って思いましたが違いました。

# ...
    volumes:
      - ./docker/mysql/my.cnf:/etc/mysql/my.cnf
# ...
$ cat ./docker/mysql/my.cnf
[mysqld]
character_set_server=utf8mb4%

雑感

シカトしてたけど、Rails側で文字コードエラーみたいなものがでたので、がんばって(?)修正した

2
0
0

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
2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?