copy database structure without data in mysql (with empty tables)

mysqldump -u user -ppass -d olddb | mysql -u user -ppass -D newdb

The new database must already exist. The -d flag in the mysqldump command prevents copying of data.

There's no space between the flag -p and the password.


You can take backup using mysqldump and restore with mysql using commandline.

For backup database

$ mysqldump -u root-pPassword -P3309 --routines --no-data testdb > "d:\dbwithnodata.sql"

For restoration of database

$ mysql -u root-pPassword -P3309 newdb < "d:\dbwithnodata.sql"

You can backup you MYSQL database structure with

mysqldump -u username –p  -d database_name > backup.sql

(You should not supply password at command line as it leads to security risks.MYSQL will ask for password by default.) And you can create create tables in database with

mysql -u username -p new_database < backup.sql

Now you can use pipe to give the output of first command as output for second one and you will no longer need backup.sql

mysqldump -u username –p  -d database_name|mysql -u username -p new_database

All tables in will be created in new_database without data.