Use the mysqldump command to back up the MySQL database script (without a comment version, suitable for production environments)
Use the mysqldump command to back up the MySQL database script (without a comment version, suitable for production environments)
Design and write considerations for this
A few days ago have friends to help write a MySQL data backup script, so there is the following through the mysqldump command backup database script, paste out to communicate with you, if there is a problem, please correct me, thank you.Implementation features:1 backing up the specified database2 Delete the backup file before the specified number of days, the def
Mysql backup script (mysqldump) in CentOS)
#! /Bin/bash # Full backup mode, generally executed on the slave machine, suitable for small and medium mysql Databases # Delete backups 15 days ago # Author: fafu_li # Time: 2015.08.10source/etc/profile # load the system environment variable source ~ /. Bash_profile # load the user environment variable set-o nounset # reference the uninitialized variable and exit
Mysql backup script (mysqldump), mysqlmysqldump
#! /Bin/bash # Full backup mode, generally executed on the slave machine, suitable for small and medium mysql Databases # Delete backups 15 days ago # Author: fafu_li # Time: 2015.08.10source/etc/profile # load the system environment variable source ~ /. Bash_profile # load the user environment variable set-o nounset # reference the uninitialized variable and
Use mysqldump to regularly back up the database script mysqldump
Script Description
All data is backed up once every 7 days, and binlog is backed up every day, that is, incremental backup.
(If there is little data, you can back up the complete data once a day, and there may be no need for incremental backup)
I am not
Mysqldump full backup shell script sharing today, the tester urged that the relevant bug database data must be backed up, and the full backup should be performed on a daily basis; for this database with a small amount of data, I feel that it is not necessary to become a mentor so that I can develop two sets of solutions for maintenance at the same time! However, if the requirement is raised, we need to solv
Mysql backup script mysqldump Usage Details, mysqlmysqldump
This example shares the mysql backup script for your reference. The specific content is as follows:
#! /Bin/bash # Full backup mode, generally executed on the slave machine, suitable for small and medium mysql Databases # Delete backups 15 days ago # Author: fafu_li # Time: 2015.08.10source/etc/profile #
Library small, about 16G, daily increment is very small, less than 100M, so with mysqldump daily full-scale backup, the backup result information sent to the email notification DBA.mysqlallbackup.sh: MySQL DataBase full Backup.# Use mysqldump--help get more detail.# 20.20.21.11:mysqla#Set-x# define Data directyMysqldir=/usr/local/mysqla# Defile User,pwdDatabackupdir=/data/backupemailfile= $dataBackupDir/ema
years, and asterisks indicate any. Date ' +%m-%d-%y ' gets the mm-dd-yyyy format for the current date.
3, a complete shell script backup MySQL Database sample
Copy Code code as follows:
#vi/backup/backup.sh
#!bin/bashCd/backupecho "You are in Backup dir"MV backup*/oldbackupecho "Old DBs are moved to Oldbackup folder"File = backup-$Now. sqlMysqldump-u user-p password database-name > $Fileecho "Your database backup successfully
; db_name. SQL
It only requests the lock table at the beginning, then refreshes the binlog, and then adds the change master statement to the exported file to specify the binlog location of the current backup, if you want to restore the file to slave, you can use this method.
1.2 restore
The file backed up with mysqldump is an SQL script that can be directly imported. There are two ways to import data.
Dir
db_name> db_name. SQLIt only requests the lock table at the beginning, then refreshes the BINLOG, and then adds the change master statement to the exported file to specify the BINLOG location of the current backup, if you want to restore the file to slave, you can use this method.
1.2 restoreThe file backed up with mysqldump is an SQL script that can be directly imported. There are two ways to import data
/db_bak2012' into table mytable_bakfields terminated by '|' enclosed by '"' lines terminated by '/r/n' ;
2. use mysqldump to export a database with fixed conditions
Let's look at several common use cases:(1) export the entire database
Mysqldump-u user name-p database name> exported file name mysqldump-u wcnc-p smgp_rj_wcnc> wcnc. SQL
(2) export a table
mysqldump to export a database with fixed conditions
Let's look at several common use cases:(1) Export the entire database
Mysqldump-u user name-p Database Name> exported file name mysqldump-u wcnc-p smgp_rj_wcnc> wcnc. SQL
(2) Export a table
Mysqldump-u user name-p database name Table Name> exported file name
database with fixed conditions
Let's look at several common use cases:(1) export the entire database
The code is as follows: mysqldump-u username-p database name> exported file nameMysqldump-u wcnc-p smgp_rj_wcnc> wcnc. SQL(2) export a table
The code is as follows: mysqldump-u user name-p database name table name> exported file nameMysqldump-u wcnc-p smgp_rj_wcnc users> wcnc_users. SQL(3) export a databa
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.