Skip to content

Instantly share code, notes, and snippets.

@yrong
Forked from lesstif/mysql-conf.sh
Created November 9, 2020 00:50
Show Gist options
  • Save yrong/92a6d434d288bad2d66268e3534265b6 to your computer and use it in GitHub Desktop.
Save yrong/92a6d434d288bad2d66268e3534265b6 to your computer and use it in GitHub Desktop.
MySQL Server configuration file for docker.
#!/bin/bash
export MYSQL_CNF=$(cat <<CNF
# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.6/en/server-configuration-defaults.html
[mysqld]
#
# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M
#
# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin
#
# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
# strict SQL mode in MySQL 5.7 is default behaviour.
sql_mode=ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
skip-character-set-client-handshake
collation-server=utf8mb4_unicode_ci
character-set-server=utf8mb4
#collation-server=utf8_unicode_ci
#character-set-server=utf8
max_allowed_packet = 256M
innodb_log_file_size=512M
transaction-isolation=READ-COMMITTED
[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
CNF
)
mkdir -p /etc/docker/mysql.conf.d
echo "${MYSQL_CNF}" > /etc/docker/mysql.conf.d/mysqld.cnf
## run docker with "-volume=/etc/docker/mysql.conf.d:/etc/mysql/mysql.conf.d"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment