Backup(dump) and Restoring a mysql DB

  • Dumping all databases of a hosts
    $ mysqldump -u root -psecret --all-databases > DATABASE.sql

other options can be used with this

    --skip-opt --force --no-data --no-create-info (see man page of mysqldump for detail)
  • Dumping a particular database
    $ mysqldump -u root --databases design > design.sql
  • Restoring backup of all databases
    $ mysql -u root -psecret < DATABASE.sql
  • Restoring backup of a particular database
    $ mysql -u root -psecret -D design < design.sql

Simple backup scripts

  • mysqldump -A –password=xxxxxx | gzip >/mysql_backup/`date +%m%d%y_%T`.sql.gz
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: