0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

MariaDB の文字コードの変更方法

Last updated at Posted at 2020-06-29

MariaDB の文字コードを UTF-8 から EUC-JP に変更する方法です。
RaspberryPi と Ubuntu 20.04 で確認しました。

次の3つの設定ファイルを編集します。

/etc/mysql/mariadb.conf.d/50-client.cnf
[client]
# Default is Latin1, if you need UTF-8 set this (also in server section)
#default-character-set = utf8mb4
default-character-set = ujis
(省略)
/etc/mysql/mariadb.conf.d/50-mysql-clients.cnf
[mysql]
# Default is Latin1, if you need UTF-8 set this (also in server section)
# default-character-set = utf8mb4
default-character-set = ujis
(省略)
/etc/mysql/mariadb.conf.d/50-server.cnf
(省略)
#character-set-server  = utf8mb4
#collation-server      = utf8mb4_general_ci
character-set-server  = ujis
collation-server      = ujis_japanese_ci
(省略)

編集したら MariaDBを再起動します。

sudo systemctl restart mariadb

確認

$ sudo mysql -uroot
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 40
Server version: 10.3.22-MariaDB-0+deb10u1 Raspbian 10

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

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

MariaDB [(none)]> show variables like 'char%';
+--------------------------+----------------------------+
| Variable_name            | Value                      |
+--------------------------+----------------------------+
| character_set_client     | ujis                       |
| character_set_connection | ujis                       |
| character_set_database   | ujis                       |
| character_set_filesystem | binary                     |
| character_set_results    | ujis                       |
| character_set_server     | ujis                       |
| character_set_system     | utf8                       |
| character_sets_dir       | /usr/share/mysql/charsets/ |
+--------------------------+----------------------------+
8 rows in set (0.009 sec)

参考ページ
MariaDB の文字コードの確認方法

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?