CSDN首页 空间 新闻 论坛 Blog 下载 读书 网摘 搜索 .NET Java 视频 接项目 求职 在线学习 买书 程序员 通知
可用分押宝游戏火热进行中... 专题改版:Java Web 专题
CSDN社区
搜索 收藏 打印 关闭
CSDN社区 >  Linux/Unix社区 >  系统维护与使用区

如何备份mysql数据库

楼主baga(八嘎)2004-09-02 19:42:06 在 Linux/Unix社区 / 系统维护与使用区 提问

rt  
  如何在linux下用脚本实现数据库的备份,按日期备份,备份前一天的数据,就剩一个小问题了,就是那中跨月跨年的日期如何实现按日期备份,比如2004年9月1日要备份2004年8月31日的数据,有没有什么好的方法能够实现,最好用shell脚本 问题点数:0、回复次数:4Top

1 楼fzjw(冰凌尘埃)回复于 2004-09-02 23:19:17 得分 0

http://article.21e.cn/view.php?pid=235&PHPSESSID=0fd067068980e850218232e5170bc909  
   
  看看mysqldump的参数吧Top

2 楼baga(八嘎)回复于 2005-03-10 16:08:29 得分 0

我自己顶,upTop

3 楼tengulre(debian core developer)回复于 2005-03-10 16:17:10 得分 0

mysqldump     Ver   8.22   Distrib   3.23.54,   for   redhat-linux-gnu   (i386)  
  By   Igor   Romanenko,   Monty,   Jani   &   Sinisa  
  This   software   comes   with   ABSOLUTELY   NO   WARRANTY.   This   is   free   software,  
  and   you   are   welcome   to   modify   and   redistribute   it   under   the   GPL   license  
   
  Dumping   definition   and   data   mysql   database   or   table  
  Usage:   mysqldump   [OPTIONS]   database   [tables]  
  OR           mysqldump   [OPTIONS]   --databases   [OPTIONS]   DB1   [DB2   DB3...]  
  OR           mysqldump   [OPTIONS]   --all-databases   [OPTIONS]  
   
      -A,   --all-databases       Dump   all   the   databases.   This   will   be   same   as  
                                                  --databases   with   all   databases   selected.  
      -a,   --all                           Include   all   MySQL   specific   create   options.  
      -#,   --debug=...               Output   debug   log.   Often   this   is   'd:t:o,filename`.  
      --character-sets-dir=...  
                                                  Directory   where   character   sets   are  
      -?,   --help                         Display   this   help   message   and   exit.  
      -B,   --databases               To   dump   several   databases.   Note   the   difference   in  
                                                  usage;   In   this   case   no   tables   are   given.   All   name  
                                                  arguments   are   regarded   as   databasenames.  
                                                  'USE   db_name;'   will   be   included   in   the   output  
      -c,   --complete-insert   Use   complete   insert   statements.  
      -C,   --compress                 Use   compression   in   server/client   protocol.  
      --default-character-set=...  
                                                  Set   the   default   character   set  
      -e,   --extended-insert   Allows   utilization   of   the   new,   much   faster  
                                                  INSERT   syntax.  
      --add-drop-table             Add   a   'drop   table'   before   each   create.  
      --add-locks                       Add   locks   around   insert   statements.  
      --allow-keywords             Allow   creation   of   column   names   that   are   keywords.  
      --delayed-insert             Insert   rows   with   INSERT   DELAYED.  
      --master-data                   This   will   cause   the   master   position   and   filename   to  
                                                  be   appended   to   your   output.   This   will   automagically  
                                                  enable   --first-slave.  
      -F,   --flush-logs             Flush   logs   file   in   server   before   starting   dump.  
      -f,   --force                       Continue   even   if   we   get   an   sql-error.  
      -h,   --host=...                 Connect   to   host.  
      -l,   --lock-tables           Lock   all   tables   for   read.  
      --no-autocommit               Wrap   tables   with   autocommit/commit   statements.  
      -K,   --disable-keys       '/*!40000   ALTER   TABLE   tb_name   DISABLE   KEYS   */;  
                                                  and   '/*!40000   ALTER   TABLE   tb_name   ENABLE   KEYS   */;  
                                                  will   be   put   in   the   output.  
      -n,   --no-create-db         'CREATE   DATABASE   /*!32312   IF   NOT   EXISTS*/   db_name;'  
                                                  will   not   be   put   in   the   output.   The   above   line   will  
                                                  be   added   otherwise,   if   --databases   or  
                                                  --all-databases   option   was   given.  
      -t,   --no-create-info     Don't   write   table   creation   info.  
      -d,   --no-data                   No   row   information.  
      -O,   --set-variable   var=option  
                                                  give   a   variable   a   value.   --help   lists   variables  
      --opt                                   Same   as   --add-drop-table   --add-locks   --all   --quick  
                                                  --extended-insert   --lock-tables   --disable-keys  
      -p,   --password[=...]     Password   to   use   when   connecting   to   server.  
                                                  If   password   is   not   given   it's   solicited   on   the   tty.  
   
      -P,   --port=...                 Port   number   to   use   for   connection.  
      -q,   --quick                       Don't   buffer   query,   dump   directly   to   stdout.  
      -Q,   --quote-names           Quote   table   and   column   names   with   `  
      -r,   --result-file=...   Direct   output   to   a   given   file.   This   option   should   be  
                                                  used   in   MSDOS,   because   it   prevents   new   line   '\n'  
                                                  from   being   converted   to   '\n\r'   (newline   +   carriage  
                                                  return).  
      -S,   --socket=...             Socket   file   to   use   for   connection.  
      --tables                             Overrides   option   --databases   (-B).  
      -T,   --tab=...                   Creates   tab   separated   textfile   for   each   table   to  
                                                  given   path.   (creates   .sql   and   .txt   files).  
                                                  NOTE:   This   only   works   if   mysqldump   is   run   on  
                                                              the   same   machine   as   the   mysqld   daemon.  
      -u,   --user=#                     User   for   login   if   not   current   user.  
      -v,   --verbose                   Print   info   about   the   various   stages.  
      -V,   --version                   Output   version   information   and   exit.  
      -w,   --where=                     dump   only   selected   records;   QUOTES   mandatory!  
      -X,   --xml                           dump   a   database   as   well   formed   XML  
      -x,   --first-slave           Locks   all   tables   across   all   databases.  
      EXAMPLES:   "--where=user='jimf'"   "-wuserid>1"   "-wuserid<1"  
      Use   -T   (--tab=...)   with   --fields-...  
      --fields-terminated-by=...  
                                                  Fields   in   the   textfile   are   terminated   by   ...  
      --fields-enclosed-by=...  
                                                  Fields   in   the   importfile   are   enclosed   by   ...  
      --fields-optionally-enclosed-by=...  
                                                  Fields   in   the   i.file   are   opt.   enclosed   by   ...  
      --fields-escaped-by=...  
                                                  Fields   in   the   i.file   are   escaped   by   ...  
      --lines-terminated-by=...  
                                                  Lines   in   the   i.file   are   terminated   by   ...  
   
  Default   options   are   read   from   the   following   files   in   the   given   order:  
  /etc/my.cnf   /var/lib/mysql/my.cnf   ~/.my.cnf  
  The   following   groups   are   read:   mysqldump   client  
  The   following   options   may   be   given   as   the   first   argument:  
  --print-defaults                 Print   the   program   argument   list   and   exit  
  --no-defaults                       Don't   read   default   options   from   any   options   file  
  --defaults-file=#               Only   read   default   options   from   the   given   file   #  
  --defaults-extra-file=#   Read   this   file   after   the   global   files   are   read  
   
  Possible   variables   for   option   --set-variable   (-O)   are:  
  max_allowed_packet         current   value:   25165824  
  net_buffer_length           current   value:   1047551  
  Top

4 楼ckc(火)回复于 2005-03-10 16:45:21 得分 0

echo   "select   curdate()-interval   1   day"   |   mysql   -s  
  可以得到昨天的日期  
  不知道这个是不是你要的Top

相关问题

  • 如何备份mysql数据库?
  • mysqldump倒出的数据库备份如何在装入Mysql数据库??
  • 如何备份数据库?
  • 如何备份数据库?
  • 如何用代码实现mysql数据库备份?
  • 如何将MySQL的数据库备份导入SQLServer2000中?
  • ~~~MYSQL数据库的备份和回存~~~
  • mysql数据库备份的问题
  • 求php备份优化mysql数据库
  • 求助:关于有1000000多数据的mysql数据库如何远程备份?

关键词

  • mysql
  • db
  • 备份
  • mysqldump
  • databases
  • 日期
  • 实现
  • options

得分解答快速导航

  • 帖主:baga

相关链接

  • CSDN Blog
  • 技术文档
  • 代码下载
  • 第二书店
  • 读书频道

广告也精彩

反馈

请通过下述方式给我们反馈
反馈
提问
网站简介|广告服务|VIP资费标准|银行汇款帐号|网站地图|帮助|联系方式|诚聘英才|English|问题报告
世纪乐知(北京)网络技术有限公司 版权所有, 京 ICP 证 020026 号
北京创新乐知广告有限公司 提供技术支持
Copyright © 2000-2007, CSDN.NET, All Rights Reserved
GongshangLogo