To export MySQL query results to csv , you usually use php to connect to mysql to execute the query, use php to generate the returned query results in csv format and then export them. But this is more troublesome and requires PHP to be installed on the server. Directly use mysql to export csv method We can use into outfile, fields terminated by, optionally enclosed by, line terminated by statements to export csv Statement format and function into outfile 'Exported directory and file name' fields terminated by 'field separator' optionally enclosed by 'Field Encloser' lines terminated by 'line separator' example: mysql -u root use test; select * from table into outfile '/tmp/table.csv' fields terminated by ',' optionally enclosed by '"' lines terminated by '\r\n'; After execution, the recorded data in talbe will be exported to the /tmp/table.csv file. Each field is separated by , and the field content is a string surrounded by ", and each record uses \r\n for line breaks. The above method of exporting MySQL query results to csv is all I want to share with you. I hope it can give you a reference. I also hope that you will support 123WORDPRESS.COM. You may also be interested in:
|
<<: How to test the maximum number of TCP connections in Linux
What is Vite? (It’s a new toy on the front end) V...
Table of contents Install Software Management Ano...
Preface: Recently, the company project changed th...
mysql full backup 1. Enable binary log and separa...
summary In some scenarios, there may be such a re...
Use the following command to create a container a...
MySQL tuning Explain tool detailed explanation an...
version: centos==7.2 jdk==1.8 confluence==6.15.4 ...
When it comes to styling our web pages, we have t...
Table of contents 1. Introduction 2. Main text 2....
Basic network configuration Although Docker can &...
Table of contents 1. Create a redis docker base i...
The mysql service is started, but the connection ...
Table of contents Overview Property settings Proc...
Starting from IE 8, IE added a compatibility mode,...