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

How to back up MySQL database

2025-04-06 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

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

Editor to share with you how to back up the MySQL database, I believe most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!

The easiest way to export table data to a text file is to use SELECT... The INTO OUTFILE statement exports the export query results directly to a file on the server host.

Use SELECT... INTO OUTFILE statement to export data

The syntax of the statement combines the regular SELECT INTO with the end of OUTFILE filename. The default output format is the same as LOAD DATA, so the following statement exports the tutorials_tbl table to C:\ tutorials.txt and uses tabs to separate the file at the end of the line:

Mysql > SELECT * FROM tutorials_tbl-> INTO OUTFILE'C:\ tutorials.txt'

You can use options to explain how to use quotation marks and delimited columns to change the record output format. Use CRLF to export the tutorial_tbl to CSV format table for the end row, using the following statement:

Mysql > SELECT * FROM passwd INTO OUTFILE'C:\ tutorials.txt'-> FIELDS TERMINATED BY', 'ENCLOSED BY' "'- > LINES TERMINATED BY'\ r\ n'

SELECT... INTO OUTFILE has the following properties:

The output file is created directly by the MySQL server, so the file name should indicate the desired file name, which will be written to the server host. There is also a statement similar to the local version of LOAD DATA without a LOCAL version.

You must have FILE permission for MySQL to execute SELECT. INTO statement.

The output file must not exist yet. It is important to prevent MySQL from making mistakes in the file.

There should be a server host or some way to retrieve the files of the login account on that host. Otherwise, SELECT... INTO OUTFILE may not have any values given.

Under UNIX, the file creator is readable and owned by the MySQL server. This means that although the file can be read, it may not be deleted

Export tables as raw data

The mysqldump program is used to copy or back up tables and databases. It can write the table output as a raw data file, or recreate the records of the INSERT statements in the table for a group.

To dump a table as a data file, you must specify a-- tab option to specify a directory for the MySQL server to write to the file.

For example, to dump from the tutorials_tbl table in the database test to a file in the C:\ tmp directory, you can use this command:

$mysqldump-u root-p-no-create-info\-tab=c:\ tmp TEST tutorials_tblpassword * these are all the contents of the article "how to back up MySQL databases". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

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