脚本实现
#!/bin/bash
for db_name in `mysql -e "show databases;"|sed 1d`
do
mkdir -p /backup/$db_name
for table_name in `mysql -e "show tables from $db_name"|sed 1d`
do
/application/mysql/bin/mysqldump --master-data=2 $db_name $table_name >>/backup/$db_name/$(date +%F)$table_name.sql
done
done
1)先取出MySQL所有库的名称
2)用for循环便利每个库
3)再便利每个库中的每个表
4)然后通过mysqldump进行备份
原文地址:http://blog.51cto.com/13543192/2132483
时间: 2024-09-29 10:03:13