how to export data from the mysql
use mysqldump
Just for the mysql/mariadb using:
| |
For the SQLite compatibility:
| |
Explanation in Details
docker container run -it --rm mysql:8 bash -c:
mysql:8is the image name and tag-itis to run the container in interactive mode--rmis to remove the container after it is stoppedbash -cis to run the command in the container
The left is a combined command to create a .my.cnf file and run mysqldump command.
echo -e '[mysqldump]\nuser=aurora\npassword=aurora' > ~/.my.cnfis to create a.my.cnffile at$HOMEwith the content1 2 3[mysqldump] user=aurora password=aurora--compactis to use the compact format, which aims to remove the Comment Syntax, the/*!and*/are removed--no-create-infois to skip theCREATE TABLEstatement, because the statement is not compatible with SQLite--skip-add-locksis to skip theLOCK TABLESstatement, because the statement is not compatible with SQLite--complete-insertis to use theINSERT INTOstatement with the column names-his to specify the db hostyour_database_nameis the database nametable1 table2 table3 table4are the exported table names, separated by space; if not specified, all tables will be exported> exported.sqlis to redirect the output to a file namedexported.sql, at the host current directory