MySQL Database Backup (3)

Source: Internet
Author: User
2. Another method that does not involve mysqldump to back up databases and tables is to directly copy database table files. Typically, this uses utilities such as cp, tar, or cpio. The example in this article uses cp. When using a direct backup method, you must ensure that the table is not used. If the server is on your

2. Another method that does not involve mysqldump to back up databases and tables is to directly copy database table files. Typically, this uses utilities such as cp, tar, or cpio. The example in this article uses cp. When using a direct backup method, you must ensure that the table is not used. If the server is on your

2Direct Copy of database backup and copy methods
The other does not involveMysqldumpYou can back up databases and tables by directly copying database table files. TypicallyCp,TarOrCpioUtility. This example usesCp.
When using a direct backup method, you must ensure that the table is not used. If the server changes a table while you are copying it, the copy will be meaningless.
The best way to ensure your copy integrity is to close the server, copy files, and restart the server. If you do not want to shut down the server, you must lock the server while performing the table check. If the server is running, the same constraints apply to copying files, and you should use the same locking protocol to make the server"Quiet down".
If the server is closed or you have locked the table you want to copy, the following shows howSamp_dbBack up the database to a backup directory (DATADIRIndicates the data directory of the server ):
% Cd DATADIR
% Cp-r samp_db/usr/archive/mysql
A single table can be backed up as follows:
% Cd DATADIR/samp_db
% Cp member. */usr/archive/mysql/samp_db
% Cp score. */usr/archive/mysql/samp_db
....
When you have completed the backup, you can restart the server (if it is disabled) or release the lock added to the table (if you want the server to run ).
To copy a database from one machine to another, just copy the file to the appropriate data directory of another server host. Make sure that the file isMyIASMFormat or two machines have the same hardware structure, otherwise your database has strange content on another host. You should also ensure that the servers on the other machine do not access them when you are installing database tables.
3Copy a database (Replicating Database)
Copy (ReplicationIs similar to copying a database to another server, but its exact meaning is to ensure full synchronization of the two databases in real time. This function will be available in3.23This article will not be detailed.

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.