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
Table of contents Install sakila Index Scan Sort ...
Don’t introduce a front-end UI framework unless i...
Table of contents 1. How to update in batches Con...
Before reading this article, I hope you have a pr...
Adobe Brackets is an open source, simple and powe...
This article introduces the content related to gi...
The author has been working on a micro-frontend p...
Original article: Ultimate IE6 Cheatsheet: How To...
In the latest version of WIN10, Microsoft introdu...
Table of contents Overview Same Origin Policy (SO...
This article shares the specific code for JavaScr...
There is a table user, and the fields are id, nic...
1. Prerequisites JDK has been installed echo $PAT...
1. Docker cross-host communication Docker cross-h...
Just like this effect, the method is also very si...