Two ways to export csv in win10 mysql

Two ways to export csv in win10 mysql

There are two ways to export csv in win10. The first is to use tools. Navicat for Mysql is a very easy-to-use mysql visualization tool that can export data in multiple formats, but it also has its limitations. The second is to export raw SQL statements.

Navicat For Mysql

Install the software, there is a green free version here, which is very easy to use, link: https://pan.baidu.com/s/1HZNzq_16M5yrq9hAMfNOmA extraction code: 848h. Open the software, establish a database connection, then select the corresponding table, right-click -> Export Wizard, and select the format.

SQL Export

There are several places where things can go wrong, so I'll list them here first.

1. The MySQL server is running with the --secure-file-priv option so it cannot execute this statement

2. SELECT list is not in GROUP BY clause

3. Exporting does not include headers

operate

1. In the MySQL installation directory, find my.ini. If it does not exist, create this file. The mysql5.7 installed on my computer did not have this file, so I created this file and installed it in the mysql directory on drive D.

2. Modify the my.ini file. If the file exists, modify it. If it does not exist, add it directly. Add secure_file_priv='' under [mysqld]

The above two steps are to solve the problem of secure-file-priv. When you reach this point, you need to restart the database service. This computer -> right-click -> Manage -> Services and Applications -> Services -> Mysql -> right-click -> Restart.

3. In Navicat For Mysql, create a query under the corresponding database (this is not necessary, it is just for the convenience of writing SQL queries). Since Mysql5.7 default ONLY_FULL_GROUP_BY semantics were introduced.

implement

SELECT @@global.sql_mode

Results will appear

Then you can see ONLY_FULL_GROUP_BY. Copy the result and remove the ONLY_FULL_GROUP_BY field. Then run SQL

SET sql_mode="STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION"
The content of sql_mode is the content left after removing ONLY_FULL_GROUP_BY.

4. Export data

SELECT 'id','name','color' FROM product UNION
SELECT `id`,`name`,`color` FROM product
 INTO OUTFILE 'product.csv' 
 FIELDS TERMINATED BY ';' 
 OPTIONALLY ENCLOSED BY '"' 
 LINES TERMINATED BY '\n';

The first line indicates that a table header needs to be added, and is enclosed in quotation marks. The second line is the corresponding field of the query. The third line is the exported file name. What symbol is used to separate the fourth line? The fifth line sets the field enclosed by symbols. The sixth line is the division of each line.

5. The data will eventually be exported to the data->databaaseName directory under the MySQL installation directory.

Summarize

The above are two ways to export csv from win10 mysql that I introduced to you. I hope it will be helpful to you. If you have any questions, please leave me a message and I will reply to you in time. I would also like to thank everyone for their support of the 123WORDPRESS.COM website!
If you find this article helpful, please feel free to reprint it and please indicate the source. Thank you!

You may also be interested in:
  • Python csv file import and export method from MySQL database
  • Python implements the method of exporting data from MySQL database table to generate csv format file
  • How to export CSV file with header in mysql
  • How to export mysql query results to csv
  • How to export MySQL data to csv format
  • How to solve the problem of Chinese garbled characters when importing and exporting csv in Mysql
  • PHP exports MySQL data to Excel file (fputcsv)

<<:  GZIP compression Tomcat and improve web performance process diagram

>>:  Implementation of vue3.0+vant3.0 rapid project construction

Recommend

The front-end must know how to lazy load images (three methods)

Table of contents 1. What is lazy loading? 2. Imp...

When to use Map instead of plain JS objects

Table of contents 1. Map accepts any type of key ...

A method of making carousel images with CSS3

Slideshows are often seen on web pages. They have...

100 ways to change the color of an image using CSS (worth collecting)

Preface “When it comes to image processing, we of...

How to remove MySQL from Ubuntu and reinstall it

First delete mysql: sudo apt-get remove mysql-* T...

Use mysql to record the http GET request data returned from the url

Business scenario requirements and implementation...

Implementation of CentOS8.0 network configuration

1. Differences in network configuration between C...

How to install and configure ftp server in CentOS8.0

After the release of CentOS8.0-1905, we tried to ...

MySQL 5.7 installation and configuration tutorial under CentOS7 64 bit

Installation environment: CentOS7 64-bit MINI ver...

Detailed explanation of MySQL database (based on Ubuntu 14.0.4 LTS 64 bit)

1. Composition and related concepts of MySQL data...

Detailed explanation of log processing of Docker containers

Docker has many log plug-ins. The default is to u...

CSS3 animation – steps function explained

When I was looking at some CSS3 animation source ...