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

Detailed explanation of Vue custom instructions and their use

Table of contents 1. What is a directive? Some co...

Example to explain the size of MySQL statistics table

Counting the size of each table in each database ...

Write a formal blog using XHTML CSS

The full name of Blog should be Web log, which me...

Use vue3 to implement a human-cat communication applet

Table of contents Preface Initialize the project ...

Summary of commonly used performance test scripts for VPS servers

Here is a common one-click performance test scrip...

Detailed tutorial on installing MySQL 8.0.20 database on CentOS 7

Related reading: MySQL8.0.20 installation tutoria...

How to add ansible service in alpine image

Use apk add ansible to add the ansible service to...

Use Docker Compose to quickly deploy ELK (tested and effective)

Table of contents 1. Overview 1.1 Definition 1.2 ...

WeChat applet implements jigsaw puzzle game

This article shares the specific code for impleme...

Sample code for implementing menu permission control in Vue

When people are working on a backend management s...

Alpine Docker image font problem solving operations

1. Run fonts, open the font folder, and find the ...

Master the commonly used HTML tags for quoting content in web pages

Use blockquote for long citations, q for short ci...

Detailed explanation of the execution process of JavaScript engine V8

Table of contents 1. V8 Source 2. V8 Service Targ...