Docker安装Mysql5.7并开启binlog

安装

docker pull mysql:5.7

创建存放映射文件夹

mkdir -p /mydata/mysql/log
mkdir -p /mydata/mysql/data
mkdir -p /mydata/mysql/conf

运行mysql

docker run --name mysql5.7 -e MYSQL_ROOT_PASSWORD=123456 -d -v /mydata/mysql/log:/var/log/mysql -v /mydata/mysql/data:/var/lib/mysql -v /mydata/mysql/conf:/etc/mysql -p 8001:3306 mysql:5.7

开启binlog(5.7默认不开启,8默认开启)

新建两个配置文件

cd /mydata/mysql/conf
touch my.cnf
touch my.conf

注意my.cnf的权限不能开太大,不让会被mysql忽略

chmod 664即可,开777会被忽略

 

修改配置文件

1、my.conf文件

vim my.conf
[client]
default-character-set=utf8
[mysql]
default-character-set=utf8
[mysqld]
init_connect='SET collation_connection = utf8_unicode_ci'
init_connect='SET NAMES utf8'
character-set-server=utf8
collation-server=utf8_unicode_ci
skip-character-set-client-handshake
skip-name-resolve
:wq!

2、my.cnf

vim my.cnf
[mysqld]
log-bin=/var/lib/mysql/mysql-bin
server-id=123654
expire_logs_days = 30
:wq!

重启mysql

docker restart mysql5.7

验证

Docker安装Mysql5.7并开启binlog_第1张图片

show variables like 'log_bin';
show variables like 'binlog_format';

你可能感兴趣的:(Ubuntu,数据库,mysql,docker,linux,mysql)