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
The div+css layout to achieve 2-end alignment is ...
Official website address: https://www.mysql.com/ ...
CSS style specifications 1. Class Selector 2. Tag...
This article mainly introduces how to call desktop...
Whether it is Samba service or NFS service, the m...
This article example shares the specific code of ...
This article example shares the specific code of ...
Table of contents 01 sql_slave_skip_counter param...
1. Font properties color, specifies the color of ...
Purpose of using Nginx Using Alibaba Cloud ECS cl...
When we work in a terminal or console, we may not...
I have been studying and reviewing the developmen...
Today I want to summarize several very useful HTML...
Apache Superset is a powerful BI tool that provid...
What is JConsole JConsole was introduced in Java ...