自动将所有mysql表转储到单独的文件中? [英] dump all mysql tables into separate files automagically?

查看:41
本文介绍了自动将所有mysql表转储到单独的文件中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将每个mysql表的转储保存到单独的文件中.手册指出此语法为

mysqldump [options] db_name [tbl_name ...]

这表示您事先知道表名称.我可以设置现在知道每个表名称的脚本,但是说我在路上添加了一个新表,却忘记了更新转储脚本.然后,我缺少了一个或多个表的转储.

是否可以自动将每个现有表转储到单独的文件中?还是我必须做一些脚本赋?查询数据库,获取所有表名,然后按名称转储它们.

如果我走脚本富路,哪些脚本语言可以访问mysql数据库?

解决方案

尽管 解决方案

The mysqldump command line program does this for you - although the docs are very unclear about this.

One thing to note is that ~/output/dir has to be writable by the user that owns mysqld. On Mac OS X:

sudo chown -R _mysqld:_mysqld ~/output/dir
mysqldump --user=dbuser --password --tab=~/output/dir dbname

After running the above, you will have one tablename.sql file containing each table's schema (create table statement) and tablename.txt file containing the data.

If you want a dump with schema only, add the --no-data flag:

mysqldump --user=dbuser --password --no-data --tab=~/output/dir dbname

这篇关于自动将所有mysql表转储到单独的文件中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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