In MySQL, how do I dump instructions to create that database again?
Let's say I have many records in this DB. But I want to clone this database structure, but start off with 0 records.
Basically, I want to "dump" the instructions to create the tables/cols of that 开发者_StackOverflow社区database. THen, I want to run these instructions.
How can I do that?
You want to run mysqldump
with the --no-data
flag.
You need to look into mysqldump. Link to the manual here http://dev.mysql.com/doc/refman/5.1/en/mysqldump.html
a) using mysqldump
b) use a visual tool and connect to your mysql database, SQLYOG for example (exist a community-freeware version that do the trick).
c) configure phpmyadmin (if you have a lamp or wamp), it allow to do the same via web.
If you have phpmyadmin, you can easily do this by navigating to your table (or database) you want to backup, then clicking on the "Export" tab. Make sure "structure" and "data" are checked.
When you're ready to import it, make sure your table (or database) doesn't exist, and click on the "import" tab. Browse to your local copy and upload it.
If you don't have phpmyadmin, and you're really not secure with mysql, you really should have your sysadmin install it for you.
精彩评论