I have Mysql database. I want to take only the skeleton of my database i.e.I want only the scripts to create Database and tables. Not the entire database back up which comes with database structure and data.
Please Help me. I Use Mysql 5.0
I have Mysql database. I want to take only the skeleton of my database i.e.I want only the scripts to create Database and tables. Not the entire database back up which comes with database structure and data.
Please Help me. I Use Mysql 5.0
mysqldump --all-databases --no-data
From MySql export schema without data:
You can do with the
--no-data
option withmysqldump
commandmysqldump -u root -p --no-data dbname > schema.sql
Jim helpfully contributes:
consider using the
--single-transaction
option if you don't want or can't do table locks.
Here is my summary about mysql dumping commands, hope to help you
backup the entire database
mysqldump -uroot -p db_name > /home/bob/my.sql
backup single table
mysqldump -uroot -p db_name table_name > /home/bob/table.sql
backup only database structure,
mysqldump -uroot -p db_name -d > /home/bob/structure.sql
backup only database data
mysqldump -uroot -p db_name -t > /home/bob/data.sql
How to execute the exported sql file? See the following
mysql -uroot -p db_name < /home/bob/my.sql
another way, Log into mysql, then
mysql> use db_name;
mysql> source /home/bob/my.sql;