I. Data Backup shortcuts
Because this method has not been verified in the official documentation, we call it a test.
Objective: To back up a MySQL database in the hostA host and restore it to the hostB
Test environment:
Operating System: WinNT4.0, Mysql3.22.34, and phpMyAdmin 2.1.0
Install MySQL database backup in hostA and create TestA Database
MySQL database backup is installed on the hostB, and no TestA database exists.
Procedure:
Start phpMyAdmin to check the database list in HostA and HostB. No TestA database exists in HostB.
Find the installation directory of MySQL database backup in HostA, and find the database directory data
In my test environment, the directory is C:/mysql/data
Find the subdirectory C:/mysql/data/TestA of the corresponding database name
Paste and copy the file to the Data directory of HostB, which is the same as that of the backup Data directory of the HostB MySQL database.
Refresh the phpMyAdmin of HostB and check the database list. We can see that TestA has appeared, and the query and modification operations are normal. The Backup recovery is successful.
Test conclusion: MySQL databases can be stored in the form of files, backup, recovery as long as the corresponding file directory can be restored, no need to use other tools to back up.
Ii. Formal method (officially recommended ):
Export the mysqldump tool that uses MySQL database backup. The basic usage is:
Mysqldump [OPTIONS] database [tables] |
If you do not specify any tables, the entire database will be exported.
RunMysqldump -- helpYou can get the option table supported by your mysqldump version.
Note: If you run mysqldump without the -- quick or -- opt option, mysqldump loads the entire result set to the memory before the export result. If you are exporting a large database, this may be a problem.
MysqldumpThe following options are supported:
Add lock tables and unlock table before each TABLE is exported. (To make it faster to insert data to the MySQL database for backup ).
Add a drop table before each create statement.
Names of columns allowed to be created as keywords. This is done by adding the table name before the column name.
Use the complete insert Statement (with the column name ).
If both the client and server support compression, all information is compressed between the two.
Use the insert delayed command to INSERT rows.
Use the new multiline INSERT syntax. (A more compact and faster insert statement is provided)
-#, -- Debug [= option_string] |
Tracking Program usage (for debugging ).
Displays a help message and exits.
-- Fields-terminated-by =...
-- Fields-enclosed-by =...
-- Fields-optionally-enclosed-by =...
-- Fields-escaped-by =...
-- Fields-terminated-by =...
|
These options are used with-T options and have the same meaning as the load data infile clause.
Load data infile syntax.
Wash the log files on the MySQL database backup server before starting the export.