Mysql automatic backup and restore transfer

An automatic backup: Save the following code * .bat batch script, then add Windows timing of operations, such as every day at 2:00 AM:
SET S =% DATE: ~ 0,4 %% DATE: ~ 5,2% DATE%: Time ~ %% 8,2: 1,1 %% ~ Time: Time %% 3,2- ~: ~ 6,2%
the mysqldump -u the root -Ppassword DatabaseName> D: \% S% _bak.sql databasename_

Description: databasename is the name of the database password for the database password, the system automatically backed up to the current date and time specified directory.

. A table structure derived only: mysqldump -uroot --no-data test> test.txt

. B export only a table of data: mysqldump -uroot --no-create-info test a> test.txt

[Note]: with mysqldump, if no arguments, dump out the file, if the table exists it will first drop table, the Table and then the Create 
, finally insert data. So pay special attention. Drop by adding or removing parameters directly remove create, such as Create-info--NO2 the mysqldump 
, the mysqldump -add-drop-= Table 'to false', of course, the safest approach is to check the correct import file before, whether the drop is present like command will destroy the original table.

Second, restore the database: mysql -u root -p databasename <d: \ databasename.sql

 

Export the entire database table structure

mysqldump -h link -u username -P3306 -p -d database name> a.sql

Export a single table data (including drop, create statements)

mysqldump -h link -u username -P3306 -p watches library name> a.sql

Export data single table (only insert statement)

mysqldump -no-create-info -h link -u username -P3306 -p watches library name> a.sql

Exporting the data of a single table (filtering conditions)

mysqldump -no-create-info -where = "id = 1" -h link -u username -P3306 -p watches library name> a.sql

Note: - in front of -no-create-info are two bars, csdn indicates a problem

mysql -h -u login link -P3306 -p

insert into tablename values (select * from tablename where condition=?)

 

 

Guess you like

Origin www.cnblogs.com/SyncNavigator-V8-4-1/p/11015863.html