MySQL database backup

Source: Internet
Author: User
Tags file copy mysql backup

As a Java developer, a database backup estimate is a must-learn.

Unfortunately, I have been doing business logic processing of front and back, database operation is not how to contact.

Today saw a bat file, is a DOS file copy and MySQL data backup command,

Learn and record it so that when to use it.

A. File copy under DOS

@echo Off@echo Start the program directory backup xcopy D:\test E:\work\back%ymd%  /y/e/I@echo Program directory backup complete @echo onpause

1.the @echo off command is to turn off every command that displays the DOS command execution process
the corresponding @echo on command is open
2. The XCOPY command is to copy all the files and directories in the previous directory into the latter file
3.%ymd% This is a date format expression that the developer is familiar with. C:\Documents and settings\administrator>xcopy/?
4./y/e/i take a look at the explanations below
xcopy/? Execute this command under DOS to see all the related commands for replication , as follows
C:\Documents and settings\administrator>xcopy/?
XCOPY Source [destination] [/a |/M] [/d[:d ate]] [/p] [/S [/E]] [/v] [/w]
[ /C] [/i] [/q] [/F] [l] [/g] [h] [/R] [/T] [/u]
[ /k] [/n] [/O] [/x] [/y] [/-y] [/z]
[/exclude:file1[+file2][+file3] ...]

source Specifies the file to be copied.
destination Specifies the location and/or name of the new file.
/A copies only files with the archive attribute set,
but does not change the properties.
/M copies only files with the archive attribute set,
and close the archive properties.
/d:m-d-y copies files that change after a specified date or a specified date.
If no date is provided, only those source time are copied
new files than the target time.
/exclude:file1[+file2][+file3] ...
specifies a list of files that contain strings. Every single string
must be in a separate line in the file. If there is any
The absolute path of the string and the file to be copied
match, that file will not be copied.
For example, specifying a string such as \obj\ or. obj would exclude
all files below the directory obj or with
file with the. obj extension.
/ p Prompt before creating each target file.
/S Copy directories and subdirectories, except empty.
/e copies directories and subdirectories, including empty.
same as/s/e. Can be used to modify/T.
/ v validates each new file.
/w prompts you to press the key before copying.
/C Continue copying even if there is an error.
/ I if the target does not exist and is copying more than one file,
It is assumed that the target must be a directory.
/ Q does not display the file name when copying.
/F The full source and destination file names are displayed when copying.
/ L Displays the files to be copied.
/g allows files that are not encrypted to be copied to
the target for encryption is not supported.
/h also copies hidden and system files.
/ R overwrites read-only files.
/T Creates a directory structure, but does not copy files.
empty directories or subdirectories are not included. /T/E includes
empty directories and subdirectories.
/ u copies only files that already exist in the target.
/k Copy Properties. General Xcopy resets the read-only attribute.
/ n is copied with the generated short name.
/o copies file ownership and ACL information.
/x Copies the file audit settings (implied/O).
/y Copy file audit settings (implied/O).
The existing target file.
/-y causes a prompt to confirm overwriting a
The existing target file.
/ z copies network files in restart mode.

command-line switches/y can be pre-set in the COPYCMD environment variable.
This may be overridden by the/-y on the command line.
5.@echo Output A prompt statement (custom)
6. Pause pauses
Second, MySQL data backup
--opt-uroot--password=root OA >e:\work\back\db.sql@echo Database backup complete @echo onpause
mysqldump--opt-uroot--password=root oa >E:\work\back\db.sql
MySQL backup command user name password database name backup address
The command needs to be executed in the bin directory under the MySQL data installation path, otherwise the internal or external command will not be reported.
MySQL Data backup example Baidu on a lot, have time to learn to organize.
These commands are easy to read and easy to understand, but they need to be practiced for good, after all, after all the light on paper.

MySQL database backup

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.