The mysqldump
command in MySQL is used to create backups of MySQL databases, allowing you to save the database structure and/or data into a SQL script. One useful option is -t
or --no-create-info
, which omits the table creation information from the output generated by mysqldump.
Example 1: Omitting table creation info for a specific database:
mysqldump -t mydatabase > mydatabase_data.sql
This command dumps only the data from the mydatabase
without the table creation statements into mydatabase_data.sql
.
Example 2: Dumping data from multiple databases without structure:
mysqldump -t --databases db1 db2 db3 > data_no_structure.sql
This command dumps only the data from databases db1
, db2
, and db3
without including table creation statements.
Example 3: Dumping data from all databases on the server:
mysqldump -t --all-databases > all_data_no_structure.sql
This command dumps only the data from all databases on the MySQL server without including table creation statements.
To verify if the command executed successfully, you can open the generated SQL file using a text editor or execute a head/tail command to check the first/last few lines of the file:
head mydatabase_data.sql
or tail -n 10 mydatabase_data.sql
Ensure that the file contains data inserts without table creation statements.
Also check similar articles.
Suppressing CREATE DATABASE Statements in mysqldump
Disabling Autocommit in mysqldump Output
Setting Network Buffer Length in mysqldump
Setting Maximum Allowed Packet Size in mysqldump
Appending Binary Log Position in mysqldump Output (Deprecated)
Discussion about this post