拉取镜像
docker pull mysql:8.0.18
编写docker compose
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
| version: "3" services: mysql: # 使用的镜像和TAG image: mysql:8.0.18 # docker重启后,是否重启 restart: always # 创建的容器名称 container_name: mysql8 # 指定端口号 ports: - "33060:3306" environment: MYSQL_ROOT_PASSWORD: admin # 挂载卷 volumes: - /data/docker/mysql/conf:/etc/mysql/conf.d - /data/docker/mysql/log:/var/log/mysql - /data/docker/mysql/data:/var/lib/mysql
|
关闭mysql binlog日志,最大连接数,表大小
1 2 3 4 5 6 7 8 9 10 11 12 13
| [mysqld] pid-file = /var/run/mysqld/mysqld.pid socket = /var/run/mysqld/mysqld.sock datadir = /var/lib/mysql secure-file-priv= NULL
# Custom config should go here
max_connections = 1000 tmp_table_size=64M max_heap_table_size=64M skip-log-bin
|
首先进到mysql 中查看下binlog状态
1 2 3 4 5 6 7
| SHOW VARIABLES LIKE 'log_bin';
+---------------+-------+ | Variable_name | Value | +---------------+-------+ | log_bin | ON | +---------------+-------+
|
/etc/mysql/my.cnf
配置
1 2 3 4 5 6 7 8 9
| echo "skip-log-bin" >> /etc/mysql/my.cnf
echo "tmp_table_size=64M" >> /etc/mysql/my.cnf echo "max_heap_table_size=64M" >> /etc/mysql/my.cnf
echo "max_connections = 1000" >> /etc/mysql/my.cnf
|
重启docker mysql ,再次查看 SHOW VARIABLES LIKE 'log_bin;'
1 2 3 4 5
| +---------------+-------+ | Variable_name | Value | +---------------+-------+ | log_bin | OFF | +---------------+-------+
|