Database backup and restore using mysqlhotcopy

By | May 31, 2013

For using mysqlhotcopy the database user must have RELOAD privilege. To set this we need root access of database.

[[email protected]]#  mysql -u root -p

Enter password :

mysql > grant reload on *.* to <user_name>;
mysql > \q

There are two options for mysqlhotcopy. “allowold” and “keepold”

–keepold :  keeps two copy of backup. One is <databasename> and other one is <databasename_old>
–allowold : keeps only one copy of backup.

Backup using mysqlhotcopy

[[email protected]]# mysqlhotcopy –host <host_name> –user <user_name> –password <password> <database_name> <path_to_new_directory> –allowold/–keepold

Restore from backup

To restore database from backup, first you need to stop mysql server. Then just copy database directory from backup path to /var/lib/mysql/  (this is the default path) directory. Please make sure that mysql is stopped before you start the restore.

Leave a Reply

Your email address will not be published. Required fields are marked *