Wednesday, May 09, 2007

Using mysqldump to backup your data

You may required to get a backup of your database , tables or get database structure and upload data another database. You can use tool mysqldump for these tasks.

The tool is located @ {MySQLInstallDir}/bin eg. /usr/local/mysql/bin

Here are few useful commands

1) Get a backup of entire database with create statement

$ mysqldump [DBName]

2) Get a backup of a database's data
$ mysqldump -t [DBName]


3) Get structure of a known table
$ mysqldump -d [DBName] [TableName]

4) Get data in a table
$ mysqldump -t [DBName] [TableName]


Use option --compact for less comment
You may need to re-direct the output to a file using ">" command at the end with a file name

No comments: