How to realize mysqldump simple backup and recovery
The following is mainly to bring you mysqldump simple backup recovery is how to achieve, I hope these contents can bring you practical use, this is also my edit mysqldump simple backup recovery is how to achieve the main purpose of this article. Okay, no more nonsense, let's go straight to the following.
backup tool
1. mysqldump: mysql's own backup tool, which belongs to logical backup;
2、cp/tar
3. xtrabackup: open source tool, supporting hot backup of InnoDB, belonging to physical backup;
mysqldump
mysqldump is a tool that comes with mysql. Its backup strategy is full backup + binary log. Support hot standby or warm standby for InnoDB and near warm standby for MyISAM.
How to use:
mysqldump [OPTIONS] database [tables] for i in {1.. 20};do mysql -e "insert into test.student(id,name,age,sex)values('$i','student$i','$[$RANDOM%80+18]','${GENDER[$RANDOM%2]}')";done
2. Authorized user rights
> GRANT ALL ON test.* TO root@'192.168.32.% ' IDENTIFIED by 'centos';
3. Backup data
h3]#mysqldump -uroot -pcentos -h292.168.32.111 --single-transaction -R --triggers -E --databases test >/app/test.sql
4. Recovery of data
]#mysql < test.sql
The second method of recovery, put the script in a directory where any user has permission to read, and enter the database to adapt to the source to read the file directly.
summary
mysqldump only supports full backup. What about data that changes after backup? You'll have to use binary logs. But again, we don't know where the binary logs are after a full backup, and we can't restore them all. Here you can add an option--master-data when backing up, this statement will be executed, it is best to choose 2 comments do not execute. One drawback of mysqldump is that it does not support delta and incremental backups.
For the above on mysqldump simple backup recovery is how to achieve, we do not think very helpful. If you need to know more, please continue to pay attention to our industry information, I believe you will like these contents.