View Full Version : Backing up MySQL Databases
sarmad54
04-30-2009, 06:05 AM
I have several times tried to make a backup for my tables in a database, but could not. I have been trying to do so from the command windows. I have installed Mysql 5 apache server and php 5 under windows platform and all of them work well. Can anyone tell me how such a back is made from the command prompt? what is the necessary command ? I have tried to follow some books but could not succeed.
stamat
05-02-2009, 06:44 AM
First to say that it would be easier for You to install phpMyAdmin on Your computer. It is free and effective (easy to setup too). Many options which You will need to backup Your tables are delivered by user friendly menues.
If phpMyAdmin is not an option for You than command prompt it is.
I am using Linux but command should be the same.
mysqldump -u user_name -p your_password database_name > File_name.sql
You can add additional directives to mysqldump, like --add-drop-table
example: mysqldump --add-drop-table -u user_name -p your_password database_name > File_name.sql
You can see list of additional directives by typing mysqldump --help or maybe mysqldump /? on Windows.
Additional options are important because You can direct mysqldump to ignore references, use compleate inserts, choose encodings and other stuff without which more complex tables can not be dumped correctly.
To restore table from prompt:
mysql - u user_name -p your_password database_name < file_name.sql
or
mysqlimport -u user_name -p your_password database_name file_name.sql
One more thing. -p your_password should somethimes used like this -pyour_password (without space between them). Try this if previous examples do not work.
Hope this helps.
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.