MySQL Programming Question:
How To Dump a Table to a File with "mysqldump"?
Answer:
If you want to dump all rows in a table from the server to a file, you can use "mysqldump" with the "-f fileName" option as show in the following tutorial exercise:
>cd mysqlin
>mysqldump -u root -r emplinks.txt test links
>type emplinks.txt
>type emplinks.txt | more
<pre>-- MySQL dump 10.10
--
-- Host: localhost Database: test
-- ------------------------------------------------------
-- Server version 5.0.24-community
...</pre>
The dump file contains SQL statements that you can use to restore the table and its data content.
>cd mysqlin
>mysqldump -u root -r emplinks.txt test links
>type emplinks.txt
>type emplinks.txt | more
<pre>-- MySQL dump 10.10
--
-- Host: localhost Database: test
-- ------------------------------------------------------
-- Server version 5.0.24-community
...</pre>
The dump file contains SQL statements that you can use to restore the table and its data content.
Previous Question | Next Question |
What Is "mysqldump"? | What Is "mysqlimport"? |