The easiest way to back up MySql database data is to back up the database using MYSQL. There are regular database backup methods. they share the same concept with other database servers, but have you ever thought about it, mySQL will have a simpler backup method using the file directory, and it will be faster and better.
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.