Using mysqldump to backup and restore your MySQL database/tables
A lot of people seem to have a problem doing backup and restoration of a MySQL database easily and quickly. However, I am going to show you how to do just that using MySQL’s built in mysqldump.exe utility through a Windows MS-DOS prompt.
There are some limitations to this utility given that WinHost customers cannot add and drop databases when trying to restore a backup, so the restore section is only recommended for new empty databases. My local environment also consisted of using MySQL version 5.5.13 so that this information would be as up to date as possible. You can find additional features, commands, and details on this tool straight from the MySQL site.
Requirements
First you are going to want to download the latest version of MySQL from the MySQL site.
Note: If you are not sure whether to download the MSI installer file or the .zip archive I would recommend to downloading MSI package. This file provides you with everything you need including a Configuration Wizard which is not included in the No-install Archive.
Now install MySQL on your local machine in the default directory C:\Program Files\MySQL\MySQL Server 5.5 since this is what Oracle recommends. Here is the installation documentation for both the MSI Installer package and the ZIP Archive:
Installer – http://dev.mysql.com/doc/refman/5.5/en/windows-using-installer.html
Archive – http://dev.mysql.com/doc/refman/5.5/en/windows-install-archive.html
Use the mysqldump utility to create a backup of you database.
- Open up a Windows command prompt.
- Click Start -> Run
- Enter “cmd” into the dialog box and click the “OK” button.
- Change the directory to the following to access the mysqldump utility.
- cd C:\Program Files\MySQL\MySQL Server 5.5\bin
- Create a dump of your current mysql database or table (do not include the bracket symbols [ ] in your commands).
- Run the mysqldump.exe program using the following arguments:
- mysqldump.exe –e –u[username] -p[password] -h[hostname] [database name] > C:\[filename].sql
- If you supplied all the arguments properly, the program will connect to your current mysql server and create a dump of your whole database in the directory you specified in your C:\ directory. There is no message that will indicate the dump has been completed, the text cursor will simply move to the next line.
Here is an example of the command line syntax:
Use the mysql utility to restore your database/table(s) dump to your WinHost MySQL database
Note: The following command will only write the data that is in the .sql file. This will not drop and create the database or truncate any of your other tables in your database. The command will script all the table data in the .sql file to your WinHost database. If you have a table name present in your WinHost database that matches a table name in the .sql file, the table will be overwritten with the new data. Otherwise the script will create a new table and populate it with the new data.
- Open up a windows command prompt.
- Click Start -> Run
- Enter “cmd” into the dialog box and click the “OK” button.
- Go to the directory that the mysql client utility is located.
- cd C:\Program Files\MySQL\MySQL Server 5.5\bin
- Import the dump of your database or table.
- Run the mysql.exe program using the following arguments.
- mysql –u[user name] -p[password] -h[hostname] [database name] < C:\[filename].sql
There are many other features and commands available if you would like to dig a little deeper into this useful utility, including setting character sets, changing ports, and selectively choosing tables to dump. In case you missed it earlier I have included the link below:
http://dev.mysql.com/doc/refman/5.5/en/mysqldump.html
Jaime
WinHost Technical Support
6 Responses to Using mysqldump to backup and restore your MySQL database/tables
Leave a Reply Cancel reply
Previous posts
- June 2013
- May 2013
- April 2013
- March 2013
- February 2013
- January 2013
- December 2012
- November 2012
- October 2012
- September 2012
- August 2012
- July 2012
- June 2012
- May 2012
- April 2012
- March 2012
- February 2012
- January 2012
- December 2011
- November 2011
- October 2011
- September 2011
- August 2011
- July 2011
- June 2011
The latest forum posts




[...] Using mysqldump to back up and restore your MySQL database/tables [...]
[...] If you need instructions on backing up your MySQL database please read our blog post article: Using mysqldump to backup and restore your MySQL database/tables. [...]
thanks good info
thanks for the info n.n
Thanks a ton..!!!
Sure Jayesh. That looks like a Kay guitar in your Gravatar…