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)?
相关问题
- sqlyog export query result as csv
- NOT DISTINCT query in mySQL
- MySQL: conduct a basic search
- Why sometimes there is one of more gap(s) in the v
- mySQL alter table on update, current timestamp
JoDev's answer worked perfectly for me with a small adjustment to the sed regular expression:
mysqldump -u [USER] -p [PASSWORD] -d --skip-opt --single-transaction [DB_SCHEMA] > [FILE.ESTENSIONE]
You can do this :
As mentioned by others, If you want
sed
to works properly, add theg
(for global replacement) parameter like this :(this only works if you have GUI Tools installed:
mysqldump --skip-auto-increment
)Thanks to this post, I was able to answer my question:
Then I just created this script:
db_bkp.sh
Then I added this to crontab:
Then in my repo I added the result,
db_structure.sql
to git and before pushing changes to prod I always check if there's any structural changes I forgot to do on all dbs.Just to use --add-drop-table like this:
mysqldump --no-data --add-drop-table
see mysql bugs and mysql dev
It is --create-options, which is included with --opt, by default, which generates the AUTO_INCREMENT table definitions.
If you only want the base tables,
If you want views, triggers and routines too,