mysql安装
docker pull mysql:8.0
#创建mysql相关目录
mkdir -p /server/data/docker/mysql/master/datadir
docker run --name mysql -p 53306:3306 --restart=always --privileged=true \
-v /server/data/docker/mysql/master/datadir:/var/lib/mysql \
-v /server/data/docker/mysql/master/mysqld.cnf:/etc/mysql/mysql.conf.d/mysqld.cnf \
-e MYSQL_ROOT_PASSWORD=ASMOklahoma \
-e TZ=Asia/Shanghai \
-d mysql:8.0 \
--character-set-server=utf8mb4 \
--collation-server=utf8mb4_unicode_ci
修改MySQL配置环境
$ vi /server/data/docker/mysql/master/mysqld.cnf
[mysqld]
pid-file = /var/run/mysqld/mysqld.pid
socket = /var/run/mysqld/mysqld.sock
datadir = /var/lib/mysql
#log-error = /var/log/mysql/error.log
# By default we only accept connections from localhost
#bind-address = 127.0.0.1
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
## 同一局域网内注意要唯一
server-id=100
## 开启二进制日志功能,可以随便取(关键)
log-bin=mysql-bin
max_connections=5000
innodb_log_file_size=256M
max_allowed_packet=34M
sql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
使用数据库连接工具连接测试
docker exec -it mysql /bin/bash
mysql mysql -uroot -p
GRANT ALL ON *.* to 'root'@'%' IDENTIFIED BY '123456';
use mysql
set global log_bin_trust_function_creators=TRUE;
FLUSH PRIVILEGES;
使用数据库连接工具连接测试
mysql>CREATE DATABASE IF NOT EXISTS test default charset utf8mb4 COLLATE utf8mb4_bin;
mysql> create user 'test'@'%' identified by '123456';
mysql>grant all privileges on test.* to 'test'@"%" identified by 'test' with grant option;
mysql>flush privileges;
标签:bin,log,mysql8,数据库,server,mysqld,mysql,docker
From: https://www.cnblogs.com/gaoyuhu/p/18027258