MySQL Backup restore

Source: Internet
Author: User
Tags mysql backup

Logical backup
MYSQLDUMP-UROOT-PAIXOCM SX > My.sql
MYSQLDUMP-UROOT-PAIXOCM sx-l > My.sql backup Lock
MYSQLDUMP-UROOT-PAIXOCM--databases ds SX > My.sql
MYSQLDUMP-UROOT-PAIXOCM--all-databases > My.sql
MYSQLDUMP-UROOT-PAIXOCM SX T1 T2 > My.sql

================================================================
Backing up a single database: mysqldump-uroot-p-B dbname > Dbname.sql
Back up all databases: Mysqldump-uroot-p--all-databases > All.sql
Backup table: mysqldump-uroot-p-B dbname--table tablename > Tablename.sql
Recovery database: Mysql-uroot-p < Name.sql
Recovery table: Mysql-uroot-p dbname < Name.sql (database must be specified)
====================================================================

Import
MYSQLDUMP-UROOT-PAIXOCM SX < My.sql
Mysql>source My.sql

Physical backup
Cold copy: First stop service (not for InnoDB engine)
Cp
Hot Copy
Mysqlhotcopy (for MyISAM engine only, server-side only, automatic locking)
Mysqlhotcopy-u root-p aixocm--socket=/var/run/mysqld/mysql5.socket ds/tmp/

Export
SELECT * from T1 to outfile '/tmp/f1.txt ' fields terminated by ', ' enclosed by ' ";
SELECT * from T1 to outfile '/tmp/f1.txt ' fields terminated by ', ' optionally enclosed by ' ";
MYSQLDUMP-UROOT-PAIXOCM-T/tmp SX T1--fields-terminated-by ","--fields-optionally-enclosed-by "" '

Import (table to exist)
Load data
Mysql>load data infile '/tmp/t1.txt ' into table ds.t1 fields terminated by ', ' enclosed by ' ";
Finally add ignore 3 lines; Not the first 3 lines
Last Add (ID, addr, name); Order of columns

Mysqlimport
Mysqlimport-uroot--socket=/var/run/mysqld/mysql5.socket ds/tmp/t1.txt--fields-terminated-by ","-- Fields-optionally-enclosed-by ' "'

Binary
/mysql/bin/mysqlbinlog--database=fox--start-date= "2013-01-22 5:00:00"--stop-date= "2013-01-22 9:00:00"/mysql/data /mysql-bin.000001 | /mysql/bin/mysql-u root-p123456-f

MySQL Backup restore

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.