在windows系统下 MYSQL 可以通过编写批处理 运用MySQL mysqldump -u root -proot --default-character-set=gbk  --databases xxxxx >C://xxxxx.sql 语句来达到定时备份数据库(xxxx是数据库的名字)linux 下也可以用 shell脚本 来实现 
但是在Linux 如何实现每天自动备份数据库而且都保存在一个特定的文件夹里并不去替换。。

解决方案 »

  1.   

    写一个shell脚本 比如叫test.sh  然后把脚本添加到crontab定时执行即可
    在每个保存的文件上加上日期 保存在一个特定的文件夹里并不去替换 比如备份到/root/backup/目录下#!/bin/bash
    day=`date "+%Y%m%d"`
    mysqldump -u root -proot --default-character-set=gbk  --databases xxxxx > /root/backup/xxxxx_$day.sql
    比如test.sh保存在/root/下 比如你要每天4点备份 那么在/etc/crontab里追加如下一句
    0 4 * * * root /root/test.sh > /dev/null 2>&1
      

  2.   

    和WINDOWS一样,不过是放在crontab中实现.