There are many purposes for exporting MySQL data, such as database backup, table structure export, table data export, and data analysis. Part1 select into outfile Let's start with the shortest and most powerful select into outfile, which is the most commonly used data collection method for small database analysis. The specific syntax is as follows: [Select statement] is a classic query SQL, which can specify columns, where conditions, group, order, limit, etc. [Export file name] is the full path of the target file. Due to the permission problem of MySQL account, we usually export the file to a temporary directory, such as /tmp/mysql/user/201810.csv 【Export parameters】
for example: select * from platform_user into outfile '/tmp/mysql/user/201810.csv' fields terminated by ',' enclosed by '"' lines starting by '\r' terminated by '\n'; If the exported data involves Chinese characters, you may see garbled characters when you open the csv file. To handle garbled characters, first make sure that the database supports Chinese (usually set UTF8 encoding) vim /etc/my.cnf, add the following options: [client] default-character-set=utf8 [mysqld] character_set_server=utf8 [mysql] default-character-set=utf8 Even if the database is already in utf8, the exported file may still contain garbled characters when downloaded locally. Are the results seen by less and tail on the server normal? Part 2 mysqldump export data As a developer or operation and maintenance personnel, mysqldump is used more frequently because it can do more things. mysqldump is a logical backup tool because it exports results, mostly in the form of SQL, and does not record the data change process. Regarding physical backup, you can refer to a book called "MySQL Technology Insider", which has a detailed description. The syntax of mysqldump is very simple, namely mysqldump [options]> dump.sql However, there are many optional parameters for options. The manual divides them into several categories, including link option, file option, data definition DDL option, Debug option, internationalization option, cluster Replication option, format option, performance option, transaction option, etc. Interested students can refer to the definition in the MYSQL official manual. Here we only introduce several common application scenarios. The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM. You may also be interested in:
|
<<: How to monitor multiple JVM processes in Zabbix
>>: How to mount a disk in Linux
Configuration Example upstream backend { server b...
There are three ways to interconnect and communic...
This article example shares the specific code of ...
Table of contents aforementioned VARCHAR Type VAR...
Execute the following command to report an error ...
Table of contents Preface Static scope vs. dynami...
Table of contents Project Background start Create...
This article shares with you how to connect pytho...
After installing docker, there will usually be a ...
Introduction There is no need to introduce Redis ...
We use the translate parameter to achieve movemen...
MySQL installation tutorial, for your reference, ...
Use HTML color blocks to dynamically display data...
Table of contents UI Design Echarts example effec...
1. Add the following dependencies in pom.xml <...