MySQL backup--mysqldump&outfile

Source: Internet
Author: User

1. Backup tool
Mysqldump Client and server side
Select outfile can only be written to the server side

2. Backup by Table unit
A. Single-table backup

Mysqldump-Uusername-PDatabaseTable1>Tableback.sqlmysql> Select *  intoOutFile'D:\someBookes\mysql\pracitce\mysql_user.sql'Fields terminated by ','     -Optionally enclosed by '"'Escaped by '#'     -Lines terminated by '\ n'  from User; Query OK,7Rows Affected (0.07sec) MySQL> ExitBye

Episode: The next backslash of the Windows operating system is ignored, and the file is created directly to the root of the D drive. Use a forward slash to create the corresponding directory, as follows:

Mysql>  UseMySQL;DatabaseChangedmysql> Select *  intoOutFile'D:/somebookes/mysql/pracitce/mysql_user.sql'Fields terminated by ','     -Optionally enclosed by '"'Escaped by '#'     -Lines terminated by '\ n'  from User; Query OK,7Rows Affected (0.00sec) MySQL>

This can only export data to the server side, how to write data to the client? Can only be wrapped under SQL write to client
Mysql-h192.168.1.119-uroot-ppasswd-e "SELECT * from Std.ygxxwh_b0;" > D:/somebookes/mysql/pracitce/stdd.sql

B. Multiple table backups
Mysqldump-uusername-p database table1 table2 >tablesback.sql

3. Backup by database unit
A. Backing up a single database
Mysqldump-uusername-p--database database1 >databaseback.sql
B. Backing up multiple databases
Mysqldump-uusername-p--database database1 database2 >databasesback.sql

4.mysqldump Common parameters
--add-drop-database add a drop database before each create.
--add-drop-tableadd a drop table before each create. (enabled by default)
--hex-blobdump binary strings (BINARY,VARBINARY,BLOB) in hexadecimal format.
--no-data Export only table structure
--single-transaction Create A consistent snapshot by dumping all tables in a single transaction. Works tables stored in storage engines which support multiversioning (INNODB).

5. Recovery Tools

Because MySQL backups are generated as SQL, the script that runs the backup is available.

Composition of the 6.Mysql log file system
A. Error log: Logging start, run, or stop is a problem with MySQL.
B. Common log: Records the established client connections and executed SQL statements.
C. Binary log: A statement that records all changes to the data. Also used for replication.
D. Slow query log: Records all queries that have been executed for more than long_query_time seconds or queries that do not use indexes.
E.innodb log: InnoDB redo Log

By default all logs are created in the MySQL data directory
You can force mysqld to close and reopen log files by refreshing the log
The log is aged when you perform flush logs or mysqladmin flush-logs or mysqladmin refresh.

MySQL backup--mysqldump&outfile

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.