mysqldump - 导出结构,没有自动增量 [英] mysqldump - Export structure only without autoincrement

查看:196
本文介绍了mysqldump - 导出结构,没有自动增量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个MySQL数据库,我试图找到一种仅导出其结构的方法,而不使用自动增量值。 mysqldump --no-data 几乎可以做这个工作,但它保持auto_increment值。有没有办法做,而不使用PHPMyAdmin(我知道它可以做到这一点)?

解决方案

你可以这样做:

  mysqldump -u root -p -h< db-host> --opt< db-name> -d  - 单交易| sed / AUTO_INCREMENT = [0-9] * \b //'> < filename> .sql 

如其他人所说,如果你想要 sed 正常工作,添加 g (for g lobal replacement)参数,如下所示:

  mysqldump -u root -p -h< db-host> --opt< db-name> -d  - 单交易| sed / AUTO_INCREMENT = [0-9] * \b // g'> < filename> .sql 

(仅在安装了GUI工具时才有效: mysqldump --skip-auto-increment


I have a MySQL database and I am trying to find a way to export its structure only, without the auto increment values. mysqldump --no-data would almost do the job, but it keeps the auto_increment values. Is there any way to do it without using PHPMyAdmin (that I know it can do it)?

解决方案

You can do this :

mysqldump -u root -p -h <db-host> --opt <db-name> -d --single-transaction | sed 's/ AUTO_INCREMENT=[0-9]*\b//' > <filename>.sql

As mentioned by others, If you want sed to works properly, add the g (for global replacement) parameter like this :

mysqldump -u root -p -h <db-host> --opt <db-name> -d --single-transaction | sed 's/ AUTO_INCREMENT=[0-9]*\b//g' > <filename>.sql

(this only works if you have GUI Tools installed: mysqldump --skip-auto-increment)

这篇关于mysqldump - 导出结构,没有自动增量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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