script to dump single record from table in mysql

15,258

Solution 1

if you check at http://dev.mysql.com/doc/refman/5.0/en/mysqldump.html you will find --where option which is the one you need.

Below follows what is stated in that reference:

--where='where_condition', -w 'where_condition'

Dump 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.

Examples:

--where="user='jimf'"
-w"userid>1"
-w"userid<1"

Solution 2

I just would like to post a more explicit answer. This is complementary to the accepted one.

mysqldump -uremote_user -premote_password -hdatabase_host remote_database_name remote_table_name --where='id=1234' --skip-add-drop-table --no-create-info
Share:
15,258
Poonam Bhatt
Author by

Poonam Bhatt

PHP, MySQL, Ajax and jQuery developer.

Updated on June 05, 2022

Comments

  • Poonam Bhatt
    Poonam Bhatt almost 2 years

    I want to dump single record from mysql table named as table1 for id = 5.

    What is mysql query for same?

    I think we can use mysqldump but i have used it with full records of table. But how to use it with single record?