my.cnf配置文件
[client]
default_character_set=utf8
[mysqld]
datadir=/var/lib/mysql/data
collation_server = utf8_general_ci
character_set_server = utf8
server-id=1
log_bin=/var/log/mysql/binlog
binlog_format=ROW
event_scheduler=ON
log_error=/var/log/mysql/error.log
general_log=ON
general_log_file=/var/log/mysql/general.log
slow_query_log=ON
slow_query_log_file=/var/log/mysql/slow.log
long_query_time=2
bind-address = 0.0.0.0
创建容器
docker run -d -p 3306:3306 --name mysql5.7 \
--privileged \
-v /opt/docker_mysql5.7/log:/var/log/mysql \
-v /opt/docker_mysql5.7/data:/var/data/mysql \
-v /opt/docker_mysql5.7/conf:/etc/mysql \
-e MYSQL_ROOT_PASSWORD='123456' \
mysql:5.7
MySQL默认sock的目录在/var/lib/mysql
使用连接mysql端口的方式备份
xtrabackup --backup --user=root --password='123456' --host=127.0.0.1 --port=3306 --parallel=3 --target-dir=/data/mysqlbackups/
查询结果