Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

MySQL data backup mysqldump and restore mysql

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

First, manual backup and restore:

1. Back up mysqldump manually. This command is executed on the cmd console:

Mysqldump-uroot-proot database [Table 1, Table 2] > File path

Mysqldump-uroot-proot tmp > d:/tmp.bak

Mysqldump-uroot-proot tmp student > d:/tmp.student.bak

2. Back up multiple databases

Mysqldump-u username-p-- databases dbname2 dbname2 > Backup.sql

The-- databases option is added, followed by multiple databases

Example: backing up test mysql database

Mysqldump-u root-p-- databases test mysql > D:\ backup.sql

The syntax for the mysqldump command to back up all databases is as follows:

Mysqldump-u username-p-all-databases > BackupName.sql

Example:

Mysqldump-u-root-p-all-databases > D:\ all.sql

3. Restore and execute mysql manually. This command is executed in the cmd console:

Mysql-u root-p [dbname]

< backup.sq   mysql -u root -p < C:\backup.sql 4、手工还原执行source,这个指令在mysql客户端执行: mysql>

Source d:\ tmp.student.bak

Second, regular backup:

1. Back up regularly under windows:

(1) create a bat file, mysqltask.bat, which contains the following contents:

Cd c:\ mysql\ bin

Mysqldump-uroot-proot tmp student > d:/tmp.student.bak

Note:

If there are spaces in the file path directory of mysqldump, then the path must be in double quotes "", that is, cd "c:\ mysql aaa\ bin"

Variable file name:

Set yy=%date:~0,4%

Set mm=%date:~5,2%

Set dd=%date:~8,2%

Set hh=%time:~0,2%

Set hh=%hh: = 0%

Set mn=%time:~3,2%

Set ss=%time:~6,2%

Set filename=%yy%%mm%%dd%%hh%%mn%%ss%.bak

(2) make mysqltask.bat into a task and schedule it regularly, usually at 2: 00 in the morning.

Control Panel > Task schedule > add Task schedule > browse and select mysqltask.bat > 2:00 every day

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report