UseMySQLProceedDatabase BackupThere are regular database backup methods, which share the same concept with other database servers, but have you ever thought that MySQL will have a simpler backup method using the file directory, and it's always better. This article introduces a simple database backup method.
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 TestA in the hostA host and restore it to the hostB host
Test environment:
Operating System: WinNT4.0, MySQL3.22.34, and phpMyAdmin 2.1.0
Install MySQL database in hostA and create TestA Database
The MySQL database is installed on the hostB machine, and there is no TestA Database
Procedure:
Start phpMyAdmin to check the database list in HostA and HostB. No TestA database exists in HostB.
Find the MySQL installation directory in HostA, and find the database directory data
In my test environment, this directory is
C: MySQLdata
Find the subdirectory of the corresponding database name
C: MySQLdataTestA
Paste and copy the file to the Data directory of HostB, which is the same as the file in the Data directory of HostB MySQL.
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 ):
MySQL MySQLdump is used for export. The basic usage is as follows:
MySQLdump [OPTIONS] database [tables]
If you do not specify any tables, the entire database will be exported.
Run MySQLdump -- help to obtain 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.
MySQLdump supports the following options:
-- Add-locks
Add lock tables and unlock table before each TABLE is exported. (To make it faster to insert data to MySQL ).
-- Add-drop-table
Add a drop table before each create statement.
-- Allow-keywords
Names of columns allowed to be created as keywords. This is done by adding the table name before the column name.
-C, -- complete-insert
Use the complete insert Statement (with the column name ).
-C, -- compress
If both the client and server support compression, all information is compressed between the two.
-- Delayed
Use the insert delayed command to INSERT rows.
-E, -- extended-insert
Use the new multiline INSERT syntax. (A more compact and faster insert statement is provided)
-#, -- Debug [= option_string]
Tracking Program usage (for debugging ).
-- Help
Displays a help message and exits.
-- Fields-terminated-by =...
-- Fields-enclosed-by =...
-- Fields-optionally-enclosed-by =...
-- Fields-escaped-by =...
-- Fields-terminated-by =...
There are many methods for backing up MySQL databases. in the previous article, we will introduce a relatively simple database backup method. In fact, there are still many efficient database backup methods, I hope the content above will help you.