Skip to content

Instantly share code, notes, and snippets.

@itkrt2y
Created December 4, 2019 11:46
Show Gist options
  • Save itkrt2y/c6c3142ef0d44b70121e4cb6a469ff00 to your computer and use it in GitHub Desktop.
Save itkrt2y/c6c3142ef0d44b70121e4cb6a469ff00 to your computer and use it in GitHub Desktop.
Docker / MySQL (utf8mb4)
version: "3"
services:
db:
image: mysql:5.7
container_name: sample-db
ports:
- 3344:3306
volumes:
- ./db/mysql:/var/lib/mysql
command:
[
"mysqld",
"--character-set-server=utf8mb4",
"--collation-server=utf8mb4_bin",
]
environment:
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: test
MYSQL_USER: test
MYSQL_PASSWORD: test
@itkrt2y
Copy link
Author

itkrt2y commented Dec 4, 2019

docker exec -it sample-db bash
mysql -u test -p

# Show character sets
SHOW VARIABLES LIKE '%char%';

# Show collations
SELECT
  DEFAULT_CHARACTER_SET_NAME,
  DEFAULT_COLLATION_NAME 
FROM
  INFORMATION_SCHEMA.SCHEMATA;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment