MySQL Backup database under Linux

Source: Internet
Author: User
Tags mysql backup mysql backup database

1. Backing up a single database

Mysqldump-u Ymoa--opt--default-character-set=utf8-p ymoadb >/app/wodsy/backup/ymoadb.sql

Mysqldump: Backup command

-U: User name

--opt: This option is shorthand, equivalent to specifying--add-drop-tables--add-locking--create-option--disable-keys--extended-insert-- Lock-tables--quick--set-charset. It can give a quick dump operation and generate a dump file that can be loaded into the MySQL server quickly. This option is turned on by default, but can be disabled with--skip-opt. To disable only the options that are sure to be enabled with-opt, use the--skip form; For example,--skip-add-drop-tables or--skip-quick.

-P: The name of the database to back up

/app/wodsy/backup/ymoadb.sql: Storage path and name after backup

2. Restore a single database:

Mysqldump-u Root--opt--default-character-set=utf8-p ymoadb </tmp/ymoadb.sql

<: In turn, you can


3. Backing up the entire database

Mysqldump-u root--opt--default-character-set=utf8-p--all-databases >/tmp/master.sql

4. Restore the entire database

5. Back up the steps of a single database



#!/bin/sh

# File:/app/wodsy/script/ymoadb_bak.sh

# by Zxk



# Database Info

Db_user= "Ymoa"

db_pass= "[Email protected]#$]


# Others VARs

Bin_dir= "/app/wodsy/mysql/bin"

Bak_dir= "/app/wodsy/backup/"

#DATE = ' DATE +%f-d yesterday '

Date= ' Date +%y%m%d-%h%m%s '


# TODO


$BIN _dir/mysqldump-u$db_user-p$db_pass--default-character-set=utf8--opt \

--triggers-r--hex-blob ymoadb|gzip > ${bak_dir}ymoadb${date}.gz



MySQL Backup database under Linux

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.