Quickly solve the problem of garbled characters and jump lines in mysql exported scv files

Quickly solve the problem of garbled characters and jump lines in mysql exported scv files

Due to work reasons, it is often not possible to achieve full onlineization (that is, all data is completed online and no import or export is required), and exporting to Excel is often slower than practicing to become an immortal. Therefore, when we export database files to local use, we often use the method of exporting to CSV format.

The csv format also often has problems such as garbled Chinese characters or skipped lines when exported, which puts you in a dilemma. Your boss wants data, but you can’t export it, which is frustrating.

1. Problem: We originally wanted to export the data in the database as shown in the left picture to its original appearance, but it became a mess on the right;

2. Solution:

a: Export to csv the same way as before;

b: Select the csv file you exported, right-click and select [Notepad] to open it;

c: File-->Save As-->Encoding select UTF-8-->Save; (The file name and save type do not need to be changed. After clicking Save, it will prompt that the file already exists. Do you want to replace it? Just select [Yes])

d: Open the file you just saved, but this time choose to open it in Excel, and then the data will be clean, just like in your database (as shown below).

Supplementary knowledge: MySQL backup -- import and export -- and solve the garbled problem

1. Export the entire database

mysqldump -u username -p database name > exported file name

mysqldump -u dbuser -p dbname > dbname.sql

2. Export a table

mysqldump -u username -p database name table name > exported file name

mysqldump -u dbuser -p dbname users> dbname_users.sql

3. Export a database structure

mysqldump -u dbuser -p -d --add-drop-table dbname >d:/dbname_db.sql

-d no data --add-drop-table add a drop table before each create statement

4. Import the database

1) Restore from file to database

mysql -uroot -p dbName < fileName

For example: restore from test.sql to database db1

mysql -uroot -p db1 <test.sql

2) Use the common source command to enter the MySQL database console.

For example, mysql -u root -p mysql>use database and then use the source command

The following parameters are script files (such as .sql used here)

mysql>source d:/dbname.sql

5. Solve the problem of garbled export

For example:

mysqldump -uroot -p --default-character-set=utf8 dbname tablename > bak.sql

Then you should also use --default-character-set=utf8 when importing data:

mysql -uroot -p --default-character-set=utf8 dbname < bak.sql

After unified encoding, the garbled characters problem in MySQL data migration is solved.

The above article on how to quickly solve the problem of garbled characters and skipped lines in mysql exported scv files is all the content that the editor shares with you. I hope it can give you a reference, and I also hope that you will support 123WORDPRESS.COM.

You may also be interested in:
  • How to solve the mysql insert garbled problem
  • How to solve the problem that mysql cannot be closed
  • Solve the problem that the MySQL database crashes unexpectedly, causing the table data file to be damaged and unable to start
  • This article solves the compatibility problem between Django 2.2 and MySQL
  • A brief discussion on the datetime format when exporting table data from MySQL to Excel
  • Quickly solve the problems of incorrect format, slow import and data loss when importing data from MySQL
  • Modification of time zone problem of MySQL container in Docker
  • pyMySQL SQL statement parameter passing problem, single parameter or multiple parameter description
  • MySQL 5.7.30 Installation and Upgrade Issues Detailed Tutorial
  • Solution to the problem of MySQL data delay jump

<<:  Detailed analysis and usage of tcpdump command under Linux

>>:  Vue binding object, array data cannot be dynamically rendered case detailed explanation

Recommend

Docker completely deletes private library images

First, let’s take a look at the general practices...

Processing ideas for decrypting WeChat applet packages on PC in node.js

Table of contents Where is the source code of the...

A brief analysis of CSS3 using text-overflow to solve text layout problems

Basic syntax The use of text-overflow requires th...

CSS to implement sprites and font icons

Sprites: In the past, each image resource was an ...

Detailed explanation of using MySQL where

Table of contents 1. Introduction 2. Main text 2....

Complete steps to build NFS file sharing storage service in CentOS 7

Preface NFS (Network File System) means network f...

mysql8.0.11 winx64 manual installation and configuration tutorial

First of all, let me talk to you about my daily l...

Troubleshooting MySQL high CPU load issues

High CPU load caused by MySQL This afternoon, I d...

Implementing a table scrolling carousel effect through CSS animation

An application of CSS animation, with the same co...

js+css to realize three-level navigation menu

This article example shares the specific code of ...

How to add java startup command to tomcat service

My first server program I'm currently learnin...

Do you know how to use mock in vue project?

Table of contents first step: The second step is ...