✕
Share it

Contact me
iPhone / iPad

Tools

Hindi Proof Reader Top Tech Blogs in India QR Code Generator
Make Money Online Earn from Blogging More Tools MS-Excel MS-Word AdSense About Lalit Contact us
TechWelkin Site Logo

TechWelkin

Tips and Tutorials on Computers, Mobiles and Internet

Last updated: 9 November 2014

MySQL: Taking Backup by Dumping Table into a File

July 29, 2008 By Lalit Kumar Leave a Comment

Learn how to take backup of a MySQL table by dumping it into a simple text file. The file can also be restored into a database whenever needed.

I often used to take backup of a single MySQL table while testing or developing an application. Taking backup of one or more tables by making a dump of them in a file is a convenient way to quickly backup and restore data without going through the proper backup of the entire database. Such a situation may arise when, for example, we want to transfer data from one server to another. Backup can be easily achieved by using the mysqldump MySQL command on shell prompt. Here is the syntax that you can use:

mysqldump -ustar -purpwd db_name table_name > file_name.sql

-u and -p options specify the user name and password for the MySQL server. There should not be a any space between -u & user name and -p & password.

Please note that it is not mandatory to keep the extension of file as .sql but because this file would contain the SQL statements -so keeping .sql makes more sense.

This dump file will also have SQL command for dropping the MySQL table if it already exist in the target database.

How to Restore MySQL Backup

In order to import the dumped table into a database, use the following MySQL command:

mysql -ustar -purpwd db_name < y1.sql

I hope this information was useful for you. Please feel free to ask if you have any questions. I will be happy to try and help you. Thank you for using TechWelkin.

Related Articles for More Information:

  1. 11 Useful MySQL Commands for Quick Reference
  2. Creating table with a name specified by a variable
Last updated: 9 November 2014 | Published on: 29 July 2008 | Authored and Edited by: Lalit Kumar and Team | Filed as: Home » Software » MySQL » MySQL: Taking Backup by Dumping Table into a File

Filed Under: MySQL

Lalit Kumar is the Principal Author and Founder of TechWelkin. He is a web explorer and he enjoys finding useful information on the Internet. He loves to put things together to create a bigger solution. Lalit is passionate about technology, languages and literature. You can contact Lalit via email (techwelkin [at] gmail [dot] com) or Facebook (facebook.com/techwelkin).

Leave a Reply Cancel reply

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

Recent Stories

  • Check Ticket Confirmation PNR Status on WhatsApp
  • Easily Capture Screen and Do Recording on iPhone / iPad
  • Consistent Video Upload is Important for YouTube Channel
  • Conditions for YouTube Channel Monetization
  • How to Get Your First 100 and 1000 Subscribers on YouTube
  • What is the Average Audience Retention for YouTube Channels?
  • Remove Activate Windows Watermark from Windows 10
  • Disadvantages of Using Google Custom Search Engine

Tools

  • Hindi Proof Reader
  • Top Tech Blogs in India
  • QR Code Generator
  • Random Word Generator
  • Strong Password Generator
  • Trace Mobile Numbers

Connect with us

  • Facebook
  • Google+
  • Twitter
  • LinkedIn
  • Pinterest
  • RSS Feed

© 2007-2019 TechWelkin.
The content is copyrighted to Lalit Kumar and may not be reproduced on other websites.
TechWelkin displays Google AdSense ads. See how Google uses data when you're on TechWelkin | Privacy Policy