Server Administration & Management

How to Backup and Restore large MySQL Database with Compression Method

If you have very large mysql database then it is very hard to backup and restore using the conventional phpmyadmin or any other programs.

To Backup MySQL Database

# mysqldump -u [username] -p [password] [dbname] > [backup.sql]

If your mysql database is very big, you might want to compress the output of mysql dump.

Just use the mysql backup command below and pipe the output to gzip, then you will get the output as gzip file.

# mysqldump -u [username] -p [password] [dbname] | gzip -9 > [backup.sql.gz]

To Restore MySQL Database, you need to create the database in target machine then use this command

# mysql -u [username] -p [password] [dbname] < [backup.sql]

Restore Compressed MySQL Database

# gunzip < [backup.sql.gz] | mysql -u [username] -p [password] [dbname]

March 3, 2012 - Posted by | MySQL | ,

No comments yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: