docker-compose 启动一个MySQL测试数据库
services:
mysql:
image: mysql:5.7
ports:
- "3306:3306"
expose:
- "3306"
environment:
- MYSQL_USER=test
- MYSQL_PASSWORD=123456
- MYSQL_DATABASE=test
- MYSQL_ROOT_PASSWORD=root
volumes:
- /home/z/env/mysql/mydir:/mydir
- /home/z/env/mysql/datadir:/var/lib/mysql
- /home/z/env/mysql/conf/my.cnf:/etc/my.cnf
- /home/z/env/mysql/source:/docker-entrypoint-initdb.d
my.cnf
[mysqld]
user=mysql
default-storage-engine=INNODB
character-set-server=utf8
character-set-client-handshake=FALSE
collation-server=utf8_unicode_ci
init_connect='SET NAMES utf8'
[client]
default-character-set=utf8
[mysql]
default-character-set=utf8