MySQL Backup and Restore

To take the backup of your mysql database, use the following command

mysqldump –-user=[username] –-password=[pass] [database-name] > [dump file]
e.g.
 shell>mysqldump –-user=root –-password=root employee > employee.sql

or

mysqldump –user=[username] –password=[pass] [database-name] > [dump file]
e.g.
 shell>mysqldump –user=root –password=root employee > employee.sql

where, [username] is your database user name
[pass] is your database password
[database-name] is the database which you want to take backup
[dump file] in this file the backup will be automatically written.

To restore your database, use the following command

 mysql –-user=[username] –-password=[pass] [database-name] < [dump file]
 e.g.
 shell>mysql –-user=root –-password=root employee < employee.sql
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: