MySQL Backup restore

Source: Internet
Author: User
Tags db2 mysql backup mysql command line

About MySQL Backup restore command operation, everything is done in cmd, not into MySQL command line


**************************************************************

Backup command: (command does not need to enter a password, enter the password will be considered the name of the database, password, etc. press ENTER will prompt input)


Mysqldump-h localhost-u root-p Test>d:/test.sql

(-h localhost can be omitted, which means to back up the native MySQL)

Next, you will be prompted for the password, and after entering the password, the database test will be successfully backed up to "d:/".

·····························

Mysqldump-u root-p Test>first_backuptest.sql

This command Windows7 under the default backup to C:\Users\Administrator, the first backup if you do not know where to back up, be sure to first confirm, right-click on my Computer, search the location of the record it for later use.

**************************************************************

Restore command: (the database must exist in the database to be restored "empty can also, the table does not have to exist", and must select the database, cannot be abbreviated to mysql-h localhost-u root- p<d:/test.sql)


Mysql-h localhost-u root-p Test<d:/test.sql

This is to restore the database from the "d:/" path.

·····························

Mysql-u root-p Test<first_backuptest.sql

This is restoring the database from the address of the MySQL default backup


--------------------------------------------------------------------------------

To back up the entire database:

Mysqldump-u root-p--all-databases>d:/all_databases2014_5_8.sql

Or

Mysqldump-u root-p-a>d:/all_databases2014_5_8.sql


To back up multiple databases:

Mysqldump-u Root-p-B db1 db2>d:/all_databases5_8_3.sql

Or

Mysqldump-u root-p--database db1 db2>d:/all_databases5_8_3.sql


Back up the table in DB table1:

Mysqldump-u Root-p DB Table1>d:/table_table1.sql


To back up multiple table tables in database db Table1,table2,table3:

Mysqldump-u root-p DB table1 table2 table3>d:/table_total.sql


Back up the schema of the database (no data, only fields):

Mysqldump-u root-p--no-data--database db1 db2>d:/dball_jg.sql

or Mysqldump-u root-p-D db>d:/db_jg2.sql



To restore the entire database:

Mysql-u root-p <d:/all_databases2014_5_8.sql


Restore multiple databases (equivalent to recovering an entire database):

Mysql-u root-p <d:/all_databases5_8_3.sql


Restore the schema of the database (no data, only fields):

Mysql-u root-p <d:/hzkj_jg.sql


Note:

1, using the--database or-B option ("--database": The front must be two short bars, if using "-B", must be capitalized), you can back up multiple databases, all parameters after this option name are identified as the database name, if this option is not taken, the second parameter will be identified as the table name;

2,--all--database equivalent-A;

3,--no-data equals-D;

4, the above instance-h localhost can be omitted, it represents the backup of the native MySQL;

5, only one must specify the database to be restored, such as Mysql-u root-p Test<first_backuptest.sql, the test after-P must have, this reason is because the backup out of the SQL file, you can when you see a feature that is not created, the following recovery database does not need to be specified because the SQL file that you are backing up has statements created and selected in the database, like these:


----Current database: ' Test '--create database/*!32312 IF not exists*/' test '/*!40100 DEFAULT CHARACTER SET UTF8 */; Use ' test ',----table structure for table ' student '--


If you do not want to specify, you can refer to the form of backup multiple databases, backup only one database, restore the time you do not need to select the database, and MySQL does not have to exist in the need to restore the database.


This article is from the "Oriental Pavilion" blog, please be sure to keep this source http://lailai.blog.51cto.com/3362373/1408908

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.