前言:数据库备份是我们日常的常规操作。当数据库出现故障或者数据出现问题时,需要通过备份文件来还原数据库来减少损失!
一、mysql容器中的数据挂载到宿主机上
创建mysql容器时,需要把mysql容器和宿主机做共享卷,把容器中的数据挂载到宿主机上。避免容器删除了数据丢失。
1、把mysql配置文件上传到对于目录,路径:/usr/local/db/mysql/my.cnf,my.cnf的配置内容如下:
# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/8.3/en/server-configuration-defaults.html
[mysqld]
#
# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M
#
# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin
#
# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2