Skip to main content

Backing Up and Restoring MySQL Database


Creating a backup is very important and common task  In this article, I will outline how to back up and restore database in MySQL.


A Simple Database Backup:
You can use mysqldump to create a backup. Here is general syntax to do that
mysqldump -u [username] -p [password] [databasename] > [backupfile.sql]
Restore using mysql
If you want to restore mysqldump file you can use mysql command.  Here is general structure of mysql command:

mysql -u [username] -p [password] [database_to_restore] < [backupfile]


Note: Use common command prompt for these commands instead of MySQL shell.

Comments

Popular posts from this blog

How to add JCalendar/ date chooser to WindowBuilder, for Swing GUI in Java?

WindowBuilder is most popular eclipse plugin for drag and drop GUI design. It supports SWT and Swing. Swing does not have a date chooser component of its own. But there are many components available that you can use. My personal favourite is JCalendar . You can add JCalendar components to your WindowBuilder  palette  by following these instructions. Download and extract JCalendar.  Right-click on the palette   in WindowBuilder Select jar file of Jcalendar select all componetnts Restart Eclipse. Now you will see JCalendar components in your  palette . For more information about  visit this page.  

Why use shopify?

Are you looking to setup an online store? You can setup your store and you can start selling in a week. There are many platforms available to use but Shopify is easiest, reliable and SEO friendly.   Not familiar with Shopify ? It is a great way to sell tour products, without worrying about managing a server, payment gateways, etc. as for a small monthly fee everything is included.  Click here to create a free trial store and start exploring. 

Loading data in MySQL Table from a Text File

There are many situation when we need to load some text data into a table. In this post I will tell you some simple steps to load Data into a MySQL table from a text File . First of all data should be in proper format Fields/ Columns should be separated by some character like space, tab or comma etc. Rows /Records/ Lines should be separated by some character like "\r\n" if there is one record per line. If data is Enclosed using some character it should be same for all columns. Create a Table in MySQL to hold data. Use LOAD DATA command to load data into the Table. Example: I have following data saved in a file c:\sample.txt "http://dbpedia.org/resource/AfghanistanHistory" "http://www.w3.org/2000/01/rdf-schema#label" "AfghanistanHistory" "http://dbpedia.org/resource/AfghanistanGeography" "http://www.w3.org/2000/01/rdf-schema#label" "AfghanistanGeography" "http://dbpedia.org/resource/Access...