MySQL backup: mysqlhotcopy and mysqldump

Source: Internet
Author: User
Tags install perl mysql backup

Sometimes the website needs to be migrated, and database migration is inevitable. However, there are usually few servers that only run a website. We need to do this without stopping the database [...]

Sometimes you need to migrate the website, and database migration is inevitable. However, there are usually few servers that only run a website. We need to do this without stopping the database and copying the data, here, you can use MySQL's built-in tools mysqldump and mysqlhotcopy

Mysqldump uses an SQL-level backup mechanism to export data tables into SQL script files. When a database is large, it occupies a large amount of system resources and supports commonly used MyISAM and InnoDB

Mysqlhotcopy is only a simple process of cache writing and file copying. It consumes much faster resources and backups than mysqldump. It is particularly suitable for large databases, but note that mysqlhotcopy only supports the MyISAM engine.

Mysqldump can be directly used after MySQL is installed.

To use mysqlhotcopy, Perl support must be installed because mysqlhotcopy is written in prel,

1 installation. MySQL has been installed, in the/usr/local/MySQL directory

Yum-y install Perl-DBI

Wget http://down1.chinaunix.net/distfiles/DBD-mysql-3.0002.tar.gz

Tar zxvf DBD-mysql-3.0002.tar.gz

CD DBD-mysql-3.0002

Perl makefile. pl-mysql_config =/usr/local/MySQL/bin/mysql_config

Make
Make Test

Make install

2. Back up a database

Mkdir-P/data/word/
/Usr/local/MySQL/bin/mysqlhotcopy-user = root-Password = 123456 word/data/Word

You can pack it, for example, word.tar.gz.

3. Recovery

Stop a MySQL database

Tar zxvf word.tar.gz

Modify permissions. Start MySQL

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.