• notice
  • Congratulations on the launch of the Sought Tech site

MySQL backup restore database batch

1.Back up the database (single table backup) bk_table.bat

The code is as follows:

mysqldump-h127.0.0.1-P3306-uroot-proot--default-character-set=gbk-t database1 table1>table1.sql
mysqldump-h127.0.0.1-P3306-uroot-proot--default-character-set=gbk-t database2 table2>table2.sql
mysqldump-h127.0.0.1-P3306-uroot-proot--default-character-set=gbk-t database2 table3>table3.sql
pause

2, restore the database (single table restore) restore.bat
The code is as follows:

mysql-h127.0.0.1-P3306-uroot-proot database1 < table1.sql
mysql-h127.0.0.1-P3306-uroot-proot database2 < table2.sql
mysql-h127.0.0.1-P3306-uroot-proot database2 < table3.sql
pause

3.Back up the database and automatically pack it into a.rar file (single table backup) bk_table.bat
The code is as follows:

mysqldump-h127.0.0.1-P3306-uroot-proot--default-character-set=gbk-t database1 table1>table1.sql
mysqldump-h127.0.0.1-P3306-uroot-proot--default-character-set=gbk-t database2 table2>table2.sql
mysqldump-h127.0.0.1-P3306-uroot-proot--default-character-set=gbk-t database2 table3>table3.sql
winrar a Db_Bak_%date:~0,10%.rar D:\DB_Backup\*.sql
DEL D:\DB_Backup\*.sql
pause

After executing batch processing, your backup data script will be compressed to your computer Db_Bak_ of D:\DB_Backup Date in the.rar file.
If it appears "'WinRAR' is not an internal or external command, nor an executable program or batch file." error, in the computer->Properties->Advanced->Environmental variables->In the Path item
Add your WinRAR path, such as: C:\Program Files\WinRAR.
4.Back up the data of the entire library
The code is as follows:

mysqldump-h127.0.0.1-P3306-uroot-proot database1 > database1.sql
Pause

Description:
1.Open Notepad-> Put the above script Copy to Notepad->Save as *.bat file, then double-click to open and execute.
2.You need to add the path of your MySql installation bin directory to the Path of the computer environment variable:
Computer->Properties->Advanced->Environmental variables->Add your Mysql in the Path item The installation bin directory path is such as: C:\Program Files\MySQL\MySQL Server 5.0\bin
or copy the batch file to C:\Program Files\MySQL\MySQL Server 5.0\bin under the bin directory for execution.
All the above have been tested, O(∩_∩)O~

Tags

Technical otaku

Sought technology together

Related Topic

1 Comments

author

atorvastatin 40mg canada & lt;a href="https://lipiws.top/"& gt;buy lipitor without preion& lt;/a& gt; buy atorvastatin 20mg generic

Xibaqd

2024-03-08

Leave a Reply

+