Mysqldump only certain fields of a table

The trick here is to not use mysqldump

mysql -u root -p -e "SELECT `field_01` AS 'new_name_01`,`field_02` as `new_name_02` FROM database.schema" -X > /tmp/output.xml

And to load it back into the new table which exists and has the fields new_name_01 & new_name_02:

mysql -u root -p --local-infile -e "LOAD XML LOCAL INFILE '/tmp/output.xml' INTO TABLE database.new_schema ROWS IDENTIFIED BY '<row>';"

Leave a Reply

Your email address will not be published. Required fields are marked *