MySQL: 𠮷(つちよし)#
データベース/テーブル utf8mb4にすること#
1
| ALTER TABLE customers_customer CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
確認:
$ echo "show variables like 'character%';" | python manage.py dbshell
Variable_name Value
character_set_client utf8mb4
character_set_connection utf8mb4
character_set_database utf8mb4
character_set_filesystem binary
character_set_results utf8mb4
character_set_server utf8mb4
character_set_system utf8mb3
character_sets_dir /rdsdbbin/mysql-8.0.28.R4/share/charsets/
character_set_system utf8mb3 が問題
接続 を utf8mb4 にすること#
django: OPTIONS/charset=utf8mb4
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
| In [1]: from django.conf import settings
In [2]: settings.DATABASES
Out[2]:
{'default': {'ENGINE': 'django.db.backends.mysql',
'HOST': 'prod-db-instance.xxxxxxxx.ap-northeast-1.rds.amazonaws.com',
'NAME': 'coresys_masters',
'USER': 'coresys_masters',
'PASSWORD': 'va0Gaighoo3Paez8',
'OPTIONS': {'charset': 'utf8mb4',
'init_command': "SET sql_mode='STRICT_TRANS_TABLES'"},
'ATOMIC_REQUESTS': False,
'AUTOCOMMIT': True,
'CONN_MAX_AGE': 0,
'TIME_ZONE': None,
'PORT': '',
'TEST': {'CHARSET': None,
'COLLATION': None,
'MIGRATE': True,
'MIRROR': None,
'NAME': None}}}
|