Dokcer import and export data in Mysql

Export

  • 1. First into the container, enter the command to extract the database files
mysqldump -u root -p rw 数据库名> 输出.sql,提取到当前容器
  • 2. Exit container into Linux; copy command input
docker cp 容器ID:/容器中的文件路径  linux中的文件路径;
  • 3. Use mobaxterm, extract the files to the current windows operating system;

Importing

In contrast to the export;

  • 1. First through mobaxterm, copy sql windows operating system files to a remote linux terminal
  • 2. Enter the copy command in linux
docker cp linux中的文件路径 容器ID:容器中的文件路径
  • 3 into the container, and then enter into the database, the new library, and then use the source command, note that the new library name and file name of the same import sql
# xx 为导入的sql的文件名(不包括.sql后缀)
create database xx;
use xx;
source 容器中的文件路径;

 

Guess you like

Origin www.cnblogs.com/whoyoung/p/10987962.html