Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MYSQL Dump only certain rows

I am trying to do a mysql dump of a few rows in my database. I can then use the dump to upload those few rows into another database. The code I have is working, but it dumps everything. How can I get mysqldump to only dump certain rows of a table?

Here is my code:

 mysqldump --opt --user=username --password=password lmhprogram myResumes  --where=date_pulled='2011-05-23' > test.sql  
like image 689
Shattuck Avatar asked May 24 '11 15:05

Shattuck


People also ask

How do I export just one row in MySQL?

If you want to export only certain rows from a MySQL database using mysqldump , you can select the records using the --where option. It dumps only rows selected by the given WHERE condition. Quotes around the condition are mandatory if it contains spaces or other characters that are special to your command interpreter.

Can Mysqldump lock tables?

By default, the mysqldump utility, which allows to back a MySQL database, will perform a lock on all tables until the backup is complete.

What is single transaction in Mysqldump?

Mysqldump with Transactions The --single-transaction flag will start a transaction before running. Rather than lock the entire database, this will let mysqldump read the database in the current state at the time of the transaction, making for a consistent data dump.


1 Answers

Just fix your --where option. It should be a valid SQL WHERE clause, like:

--where="date_pulled='2011-05-23'"

You have the column name outside of the quotes.

like image 127
AJ. Avatar answered Sep 29 '22 07:09

AJ.