Mysqldump help

32 views
Skip to first unread message

srijith c

unread,
Jun 7, 2011, 7:38:47 AM6/7/11
to bangal...@googlegroups.com
Hi all,
In mysqldump command is it possible to insert "sql conditions"?

So that i can dump the database which contains the data what i need.

Please help.....

Thanks


Piyush Gupta

unread,
Jun 7, 2011, 7:43:32 AM6/7/11
to bangal...@googlegroups.com
-w, --where='where-condition' #Dump on selected records .

Regards,
Piyush Gupta
s : mba.piyushgupta
w: blog.thebrainpoint.com

Subbu

unread,
Jun 7, 2011, 1:27:13 PM6/7/11
to bangal...@googlegroups.com, bab...@gmail.com
You can use --where option as Piyush suggested. Check out mysqldump documentation as well. It has quite a few options. http://dev.mysql.com/doc/refman/5.1/en/mysqldump.html

srijith c

unread,
Jun 7, 2011, 11:32:26 PM6/7/11
to bangal...@googlegroups.com
Hi,
Thanks for quick help,

MySQLDump works great for the single table:
Ex:
mysqldump "--where=name='project1" " database1 projects  > backup.sql

But it is throwing error when i include another table  whichis having foreign key relation with the first table:
Ex:
mysqldump "--where=projects.name='project1'" "--where=sub_projects.foreignKey=projects.primaryKey" cap_db projects sub_projects > backup.sql

Error Trace:

mysqldump: mysqldump: Couldn't execute 'SELECT /*!40001 SQL_NO_CACHE */ * FROM `sub_projects` WHERE sub_projects.foreignKey=projects.primaryKey': Unknown column 'sub_projects.foreignKey' in 'where clause' (1054)
mysqldump: Got error: 1054: Unknown column 'sub_projects.foreignKey' in 'where clause' when retrieving data from server

Is it possible to include two tables which have a foreignkey relation in mysqldump?

Thanks




Subbu

unread,
Jun 9, 2011, 5:24:06 AM6/9/11
to bangal...@googlegroups.com, bab...@gmail.com
Why not execute your query within mysql shell and the output the query results to an external file? This way you don't have to use mysqldump.
Reply all
Reply to author
Forward
0 new messages