mysql> show variables like ‘char%’;
+————————–+—————————-+
| Variable_name | Value |
+————————–+—————————-+
| character_set_client | latin1 |
| character_set_connection | latin1 |
| character_set_database | latin1 |
| character_set_filesystem | binary |
| character_set_results | latin1 |
| character_set_server | latin1 |
| character_set_system | utf8 |
| character_sets_dir | /usr/share/mysql/charsets/ |
+————————–+—————————-+
8 rows in set (0.12 sec)
docker-compose.yml
db: build: ./db env_file: .env ports: - "3306:3306" volumes: - db-data:/var/lib/mysql - ./db/initial.sql:/docker-entrypoint-initdb.d/initial.sql command: mysqld --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci
./db/my.cnf
[mysql] default-character-set=utf8mb4 [mysqld] character-set-server=utf8mb4 collation-server=utf8mb4_bin [client] default-character-set=utf8mb4
./db/Dockerfile
FROM mysql:5.7.19 ADD ./my.cnf /etc/mysql/my.cnf RUN chmod 644 /etc/mysql/my.cnf
$ sudo docker-compose build
$ sudo docker-compose up -d
$ sudo docker exec -it 325 bash
# mysql -u root -p
mysql> show variables like ‘char%’;
+————————–+—————————-+
| 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 | utf8 |
| character_sets_dir | /usr/share/mysql/charsets/ |
+————————–+—————————-+
$ sudo apt-get update
$ apt-get install locales locales-all
$ dpkg-reconfigure locales
275. ja_JP.UTF-8 UTF-8 & 3
$ apt-get install vim
$ export LANG=ja_JP.UTF-8
$ vim ~/.bashrc
$ vim ~/.inputrc
set convert-meta off set meta-flag on set output-meta on
$ source ~/.inputrc
これで、Docker mysqlの日本語入力が可能となりました。
やばすぎるな、これ。