Saturday, 5 May 2012

How to take the dump of MySQL database?

For Windows :-

Open a notepad and copy

            C:\"Program Files"\MySQL\"MySQL Server 5.5"\bin\mysqldump -u root -p  --add-drop-table database_name > database_backup.sql

 and save as a batch(.bat) file (check whether your mysql path is right or not)
               Where U= user name of the databas (eg: root)
                            P= password of database
                             database_name = is a database of which you want to take backup
                             database_backup.sql= is a backup file of that database

 To run this batch file just click on the batch file it will create a .sql file
For Linux server:-

                                 mysqldump -u root -proot  --all-databases --port=3306  | gzip >  backup_database-`date +%Y-%m-%d`.sql.gz

and save as a .sh file and to run this file type
it will create a .sql.gz file with current data string.

No comments: