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/ 查询结果