docker 安装mysql

docker search mysql

下载镜像

docker pull mysql:5.7

启动服务

docker run -d -p 9306:3306 --privileged=true -v /usr/local/cohesion/mysql/conf/my.cnf:/etc/mysql/my.cnf -v /usr/local/cohesion/mysql/data/:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=cohesion_123 --name mysql5.7 mysql:5.7

 my.cnf配置代码

[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
# Settings user and group are ignored when systemd is used.
# If you need to run mysqld under a different user or group,
# customize your systemd unit file for mariadb according to the
# instructions in http://fedoraproject.org/wiki/Systemd
character_set_server=utf8mb4
init_connect='SET NAMES utf8'
lower_case_table_names = 1
sql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
max_connections=5000
default-time_zone = '+8:00'
skip-grant-tables
[mysqld_safe]
log-error=/var/log/mariadb/mariadb.log
pid-file=/var/run/mariadb/mariadb.pid

#
# include all files from the config directory
#
#i!includedir /etc/my.cnf.d
#lower_case_table_names = 1
#sql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVI
原文地址:https://www.cnblogs.com/sz-jack/p/10678019.html