Saturday, March 2, 2013

How to Backup and Restore MySQL database in Linux



To take a backup of MySQL database or databases, the database must exist in the database server and you must have access to it. The format of the command would be.
# mysqldump -u [username] –p[password] [database_name] > [dump_file.sql]
The parameters of the said command as follows.
  1. [username] : A valid MySQL username.
  2. [database_name] : A valid Database name you want to take backup.
  3. [dump_file.sql] : The name of backup dump file you want to generate.
Example, Backup Database  :- 

# mysqldump -u suraj –p moodle > /home/suraj/moodle.sql
Example, Restore Database  :-
# mysql -u suraj –p moodle < /home/suraj/moodle.sql

No comments:

Post a Comment