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 directoryDATADIRIndicates 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 DatabaseReplicating Database)
CopyReplicationIs 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.