Chinaunix首页 | 论坛 | 博客
  • 博客访问: 2306258
  • 博文数量: 266
  • 博客积分: 5485
  • 博客等级: 大校
  • 技术积分: 3695
  • 用 户 组: 普通用户
  • 注册时间: 2007-06-20 11:05
个人简介

多读书,多做事,广交朋友,趣味丛生

文章分类

全部博文(266)

分类: Mysql/postgreSQL

2012-02-26 14:48:47

  1. MySQL 5 has introduced some new interesting features, like stored procedures and triggers.
  2. I will show in this small post how we can backup and restore these components using mysqldump.
  3. mysqldump will backup by default all the triggers but NOT the stored procedures/functions. There are 2 mysqldump parameters that control this behavior:
  4. –routines – FALSE by default
  5. –triggers – TRUE by default
  6. This means that if you want to include in an existing backup script also the triggers and stored procedures you only need to add the –routines command line parameter:
  7. mysqldump <other mysqldump options> --routines > outputfile.sql
  8. Let’s assume we want to backup ONLY the stored procedures and triggers and not the mysql tables and data (this can be useful to import these in another db/server that has already the data but not the stored procedures and/or triggers), then we should run something like:

  9. mysqldump --routines --no-create-info --no-data --no-create-db --skip-opt <database> > outputfile.sql

  10. and this will save only the procedures/functions/triggers of the <database>. If you need to import them to another db/server you will have to run something like:

  11. mysql <database> < outputfile.sql

例如:
mysqldump --routines --no-create-info --no-data --no-create-db --skip-opt db -uroot -p123456> /home/jack/outputfile.sql
阅读(1861) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~