SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Member
    Join Date
    Jul 2005
    Posts
    19
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    [Solved] Using "mysqldump" to export individual fields...

    Hi all:

    I've spent a lot of time searching around for an answer here, but have been unable to find one. What I'm looking to do is to use "mysqldump" to export two specific fields form a certain table, rather than exporting the entire table. This table contains near 20 fields, but I just need two. The command I'm using so far is:

    mysqldump -u USERNAME -p DATABASE --tables TABLE --xml > fields.xml

    I just need to know now how to fine-tune it so I can specifiy the two tables I need. I plan to use this command to regularly backup this particular part of the database, and I'm unsure if that can be done via another method or not.

    Thanks for any help,

    Ds
    Last edited by Deathspawner; Feb 9, 2009 at 23:05. Reason: Problem was solved.

  2. #2
    SitePoint Addict
    Join Date
    Sep 2007
    Posts
    371
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    AFAIK you can't use mysqldump to export specific columns from a table, either it will dump all the fields or none. Either write a custom script or look for some other software on google.

  3. #3
    SitePoint Member
    Join Date
    Jul 2005
    Posts
    19
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi dman_2007:

    Thanks for the info. I just figured out an alright solution though. It just makes more sense to run a SQL command with password intact and achieve virtually the same thing:

    mysql -u USERNAME --password=PASSWORD --database=DATABASE --execute='SELECT `FIELD`, `FIELD` FROM `TABLE` LIMIT 0, 10000 ' -X > file.xml

    That works fine, so I think I'll stick with it.

    Thanks!

  4. #4
    SitePoint Addict
    Join Date
    Sep 2007
    Posts
    371
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Clever solution, well done!


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •