MySQL Fast database backup and automatic backup Bat processing method

Source: Internet
Author: User
Tags mysql tutorial

MySQL Tutorial quick Database Tutorial Backup and automatic backup Bat processing method, the following is the bat batch method, followed by the common SQL data various backup commands.

@echo off
Echo.
echo MySQL Database backup

Echo *****************************
Echo.
Echo is%date% today.
echo Time is%time%.
Echo.
Echo *****************************


Set "ymd=%date:~,4%%date:~5,2%%date:~8,2%"

MD "d:%ymd%"

"C:Program filesmysqlmysql Server 5.1binmysqldump"--opt-q-uroot-proot--default-character-set=gbk mysql > d:%ymd% Mysqlteble.sql "

Echo.

echo MySQL database backup complete, please check ...

Echo.
Echo.
Pause

Above is the bat backup method,

Commands for backing up the MySQL database

Mysqldump-hhostname-uusername-ppassword databasename > Backupfile.sql
Backing up the MySQL database for a deleted table format
Backing up the MySQL database is a format with a deleted table that allows the backup to overwrite the existing database without having to manually delete the original database.

Mysqldump-–add-drop-table-uusername-ppassword databasename > Backupfile.sql
Directly compress MySQL database to backup

Mysqldump-hhostname-uusername-ppassword DatabaseName | gzip > backupfile.sql.gz
Backing up a MySQL database (some) tables

Mysqldump-hhostname-uusername-ppassword databasename specific_table1 specific_table2 > Backupfile.sql
Backup multiple MySQL databases at the same time

Mysqldump-hhostname-uusername-ppassword–databases databasename1 databasename2 databasename3 > Multibackupfile.sql
Just back up the database structure

Mysqldump–no-data–databases databasename1 databasename2 databasename3 > Structurebackupfile.sql
Back up all databases on the server

Mysqldump–all-databases > Allbackupfile.sql
command to restore MySQL database

Mysql-hhostname-uusername-ppassword DatabaseName < Backupfile.sql
Restoring a compressed MySQL database

Gunzip < backupfile.sql.gz | Mysql-uusername-ppassword DatabaseName
Transferring a database to a new server

Mysqldump-uusername-ppassword DatabaseName | mysql–host=*.*.*.*-c databasename

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.