After the server uses Docker, make a note of the backup and restore of the database:
Since docker is not an entity, to export the mysql database to the physical machine, the command is as follows:
1: Check the mysql running name
#docker ps
result:

2: Backup the docker database
From the results of the first step, we can see that our mysql is running in a docker container called mysql_server. And the database we want to back up is in it, called test_db. The username and password of mysql are both root, and we will back up the file to the /opt/sql_bak folder.
docker exec -it mysql_server [docker container name/ID] mysqldump -uroot -p123456 [database password] test_db [database name] > /opt/sql_bak/test_db.sql [export table path]
3: Import the docker database
method 1:
Import the file into the container first #docker cp **.sql [Container name]:/root/ into the container #docker exec -ti [container name/ID]sh Import file into database # mysql -uroot -p [database name] < ***.sql
Method 2:
docker exec -i mysql_server [docker container name/ID] mysqltest_db_copy [database name] < /opt/sql_bak/test_db.sql [local data table path]
Note: The parameter -it needs to be replaced with -i here,
otherwise an error will be reported: " the input device is not a TTY "