MySql export schema without data

2020-01-25 02:59发布

I'm using a MySql database with a Java program, now I want to give the program to somebody else.

How to export the MySql database structure without the data in it, just the structure?

标签: mysql sql
11条回答
乱世女痞
2楼-- · 2020-01-25 03:42

You can use the -d option with mysqldump command

mysqldump -u root -p -d databasename > database.sql
查看更多
老娘就宠你
3楼-- · 2020-01-25 03:42

You Can Use MYSQL Administrator Tool its free http://dev.mysql.com/downloads/gui-tools/5.0.html

you'll find many options to export ur MYSQL DataBase

查看更多
Evening l夕情丶
4楼-- · 2020-01-25 03:47

If you want to dump all tables from all databases and with no data (only database and table structures) you may use:

mysqldump -P port -h hostname_or_ip -u username -p --no-data --all-databases > db_backup.sql

This will produce a .sql file that you can load onto a mysql server to create a fresh database. Use cases for this are not many in a production environment, but I do this on a weekly basis to reset servers which are linked to demo websites, so whatever the users do during the week, on sunday nights everything rolls back to "new" :)

查看更多
ゆ 、 Hurt°
5楼-- · 2020-01-25 03:51

Beware though that --no-data option will not include the view definition. So if yo had a view like following create view v1 select a.id AS id, a.created_date AS created_date from t1; with --no-data option, view definition will get changed to following create view v1 select 1 AS id, 1 AS created_date

查看更多
▲ chillily
6楼-- · 2020-01-25 03:53

you can also extract an individual table with the --no-data option

mysqldump -u user -h localhost --no-data -p database tablename > table.sql
查看更多
登录 后发表回答