Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Methods and steps of backing up MySQL database

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly introduces "the methods and steps of backing up MySQL database". In the daily operation, I believe that many people have doubts about the methods and steps of backing up MySQL database. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful to answer the doubts of "methods and steps of backing up MySQL database". Next, please follow the editor to study!

Using MySQL for database backup, there is a very formal database backup method, which has the same concept as other database servers, but have you ever thought that MySQL will have a simpler backup method using file directories, and it will be better soon.

1. Shortcut to data backup

Since this method has not been verified by official documents, let's call it an experiment.

Purpose: to back up a MySQL database TestA in the hostA host and restore it to the hostB machine

Test environment:

Operating system: WinNT4.0,MySQL3.22.34,MyAdmin 2.1.0

Install MySQL in hostA and set up TestA database

Host B machine installs MySQL database, no TestA database

Methods and steps:

Start phpMyAdmin to view the list of databases in HostA and HostB. There is no TestA database in HostB.

Locate the installation directory of MySQL in HostA and find the database directory data

In my experimental environment, this catalog is

C:MySQLdata

Find the subdirectory of the corresponding database name

C:MySQLdataTestA

Paste and copy to the Data directory of HostB. The HostA is the same as the files in the HostB MySQL data directory.

Refresh the phpMyAdmin of HostB and take a look at the database list. We can see that TestA has appeared, and the operations such as query modification are normal, and the backup recovery is successful.

Conclusion: the database of MySQL can be saved, backed up and restored in the form of files, as long as the corresponding file directory is restored, and there is no need to use other tools to back up.

Second, formal methods (official recommendations):

To export the MySQLdump tool to be used with MySQL, the basic usage is:

MySQLdump [OPTIONS] database [tables]

If you do not specify any tables, the entire database will be exported.

By executing MySQLdump-help, you can get a list of options supported by your version of MySQLdump.

Note that if you run MySQLdump without the-quick or-- opt option, MySQLdump will load the entire result set into memory before exporting the results, which may be a problem if you are exporting a large database.

MySQLdump supports the following options:

-- add-locks

Add LOCK TABLES before each table is exported and then UNLOCK TABLE. (for faster insertion into the MySQL).

-- add-drop-table

Add a drop table before each create statement.

-- allow-keywords

Allows you to create column names that are keywords. This is done by adding the table name before the column name.

-c,-- complete-insert

Use the full insert statement (with column names).

-C,-- compress

If both the client and the server support compression, compress all the information between them.

-- delayed

Insert a row with the INSERT DELAYED command.

-e-- extended-insert

Use the new multiline INSERT syntax. (give more compact and faster insert statements)

-#,-- debug [= option_string]

Track the use of the program (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=...

At this point, the study of "the methods and steps of backing up MySQL database" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report