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

How to set up automatic backup MySQL server in WINDOWS

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

Share

Shulou(Shulou.com)05/31 Report--

How to set up an automatic backup MySQL server in WINDOWS? in view of this problem, this article introduces the corresponding analysis and solution in detail, hoping to help more partners who want to solve this problem to find a more simple and easy way.

Under windows:

Specifically, if we need to use the task scheduler to run automatically, we should perform the following steps:

1. Click the "start" button, and then select "programs" → "attachment" → "system tools" → "Task Plan" (or "set" → control panel "→" Task Plan) to start the task schedule manager for Windows 2000.

two。 Double-click the add Task schedule icon in the Task schedule window to launch the system's Task Planning Wizard, and then click the next button to select the application that needs to run automatically in the list of programs given. then click the next button.

Set the appropriate task schedule name and select the frequency of time to automate this task (such as daily, weekly, monthly, once, every time you start your computer, each time you log in, etc.), and then click the next button.

At this time, the system will require users to set the specific time for the program to run, such as what time, when, which time period to run, etc., we just need to set up according to our own needs.

4. Next, the system will ask the user to set the appropriate user name and password (as shown in figure 5) so that the system can run automatically in the future.

5. Finally, we only need to click the "finish" button to add the corresponding task to the task scheduler in Windows 2000, after which it will automatically "remember" the task. Once the system time and related conditions match the plan set by the user, it will automatically call the application specified by the user, which is very convenient (every time you start Windows 2000, the task scheduler will automatically start and run in the background. Ensure that the user's plan can be carried out on time.

Now to test the success of the task you just built, right-click the "php" program icon (shown in figure 6) and select "run" from the pop-up menu. In general, as long as the program icon is activated and run in this way, it can start normally. If the operation fails, you can check whether the user and password are set correctly, and to determine whether the "Task Scheduler" service has been started. I turned it off in order to save system resources and caused it to fail, which made me look for it for most of the day. In addition, you can also check the "system log" to see what caused the failure.

Now that we've talked so much about the application of task planning, let's get to the point. Here are two examples:

First, let PHP run regularly!

1. Edit the following code and save it as test.php:

2. Add a task plan and enter the command D:/php4/php.exe-Q D:/php4/test.php at this step (shown in figure 2)

3. Set the time to run every 1 minute, and then run the task.

4. Now let's see if the contents of the d:/php4/test.txt file are successful. If the content is shown below, then congratulations on your success.

2003-03-03 11:08:01 Let PHP run regularly!

2003-03-03 11:09:02 Let PHP run regularly!

2003-03-03 11:10:01 Let PHP run regularly!

2003-03-03 11:11:02 Let PHP run regularly!

Second, make it possible for MYSQL to achieve automatic backup!

1. Edit the following code and save it as backup.php. If you want to compress it, you can copy a rar.exe:

Backup Ver 0.01, for Win95/Win98/WinNT/Win2000/WinXP on i32

Copyright (C) 2000 ptker All rights reserved.

This is free software,and you are welcome to modify and redistribute it

Under the GPL license

PHP Shell script for the backup MySQL database.

Usage:

Can be database name you would like to backup.

With the-help, or? Options, you can get this help and exit.

2. Add a task plan and enter the command at this step (shown in figure 2):

D:/php4/php.exe-Q D:/php4/backup.php databasename

3. Set the time to run once a day, and then run the task.

4. Finally, a rar file composed of database name and current time will be generated in the d:/php4/ directory.

Under linux:

Shell script for automatically backing up database under MySQL:: Linux

The program on the Linux server updates the MySQL database every day, so I think of writing a shell script, combined with crontab, to back up the database regularly. In fact, it is very simple, mainly using the mysqldump command that comes with MySQL.

The script reads as follows:

#! / bin/sh

# File: / home/mysql/backup.sh

# Database info

DB_NAME= "test"

DB_USER= "username"

DB_PASS= "password"

# Others vars

BIN_DIR= "/ usr/local/mysql/bin"

BCK_DIR= "/ home/mysql/backup"

DATE= `date +% F`

# TODO

$BIN_DIR/mysqldump-- opt-u$DB_USER-p$DB_PASS $DB_NAME | gzip > $BCK_DIR/db_$DATE.gz

Then use to add this script to the / etc/crontab scheduled task:

01 5 * 0 mysql/ home/mysql/backup.sh

Well, the system automatically runs backup.sh files to back up the MySQL database at 5:01 every Sunday morning.

/ home/www/inc/back

This is the answer to the question about how to set up an automatic backup MySQL server in WINDOWS. I hope the above content can be of some help to you. If you still have a lot of doubts to be solved, you can follow the industry information channel to learn more about it.

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