Last night I needed to generate a script of a local MySQL database, dump the data, then load it on a remote server. I didn’t have my handy dandy SQL Server Integration Services toolset, but did find a pretty cool utility: http://dev.mysql.com/doc/refman/5.1/en/mysqldump.html. Running this program will generate a DROP/CREATE script for your database, and if you want, generate the INSERT statements for all the data in your tables. So here are the steps:
1. Open your command prompt
2. Navigate to your MySQL’s bin directory . For me, it is located in c:\program files\MySQL\MySQL Server 5.1\bin.
3. Run the following command:
mysqldump –-user [your username] –-password=[your password] [database you want scripted] > [name of the file]
There are tons of switches, make sure you check out the MySQL documentation (http://dev.mysql.com/doc/refman/5.1/en/mysqldump.html). It takes what appears to be almost a nanosescond, and it’s done! You can then open the file, copy the contents, and then paste it into whatever MySQL tool you use to manage your database. I was using phpMyAdmin and ran the script without any issues.




