Win10版 MySQL の文字コードが反映されない

Win10版の8.0.24 MySQL Community Serverで文字コードがUTF8に反映されなかったときの対処法

C:\\ProgramData\\MySQL\\MySQL Server 8.0 ディレクトリにあるmy.iniを以下のように変更した

[client]に”default-character-set = utf8″

[client]
default-character-set=utf8
# pipe=

# socket=MYSQL

port=3306

[mysql]に”default-character-set=utf8”を追記

[mysql]
no-beep

# default-character-set=
default-character-set=utf8

# SERVER SECTION
# ----------------------------------------------------------------------
#
# The following options will be read by the MySQL Server. Make sure that
# you have installed the server correctly (see above) so it reads this 
# file.
#
# server_type=3

[mysqld]に”character-set-server=utf8″と”skip-character-set-client-handshake”を追記

[mysqld]
skip-character-set-client-handshake
# The next three options are mutually exclusive to SERVER_PORT below.
# skip-networking
# enable-named-pipe
# shared-memory

# shared-memory-base-name=MYSQL

# The Pipe the MySQL Server will use
# socket=MYSQL

# The TCP/IP Port the MySQL Server will listen on
port=3306

# Path to installation directory. All paths are usually resolved relative to this.
# basedir="C:/Program Files/MySQL/MySQL Server 8.0/"

# Path to the database root
datadir=C:/ProgramData/MySQL/MySQL Server 8.0\Data

# The default character set that will be used when a new schema or table is
# created and no character set is defined
# character-set-server=
character-set-server=utf8

反映されているか確認

Windowsの”サービス”のMySQL80を再起動

MySQL サービス実行確認

コマンドプロンプトを起動してmysqlにログイン後、コマンド”show variables like ‘char%’;”を実行

MySQL show variables like 'char%';

コメントする