Mysqldumper:分别转储每个表 [英] Mysqldumper: Dumping each table separately

查看:119
本文介绍了Mysqldumper:分别转储每个表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



背景:我想用git跟踪那些转储并使用预先提交的钩子



示例:
我有一个包含10个表(table1 - table10)的模式。
现在我想每个表的文件:
table1.sql
table2.sql
...



这个工作吗?



为什么stackoverflow不喜欢我的问题?

解决方案

这应该在shell中工作:

  for mysql in`mysql --skip-column-names -u [用户名] -p [密码] [dbname] -e'显示表;'`; do 
mysqldump -u [用户名] -p [密码] [db名称] $ x> $ x.sql
完成


How can I dump each mysql table separately with mysqldump?

Background: I want to track those dumps with git and using the pre-commit hook

Example: I have a schema with 10 tables (table1 - table10). now I want a file per table: table1.sql table2.sql ...

So how gonna this work?

Snd why stackoverflow don't like my question?

解决方案

This should work in a shell:

for x in `mysql --skip-column-names -u [username] -p[password] [dbname] -e 'show tables;'`; do
     mysqldump -u [username] -p[password] [db name] $x > "$x.sql"
done

这篇关于Mysqldumper:分别转储每个表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆