In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-06 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
Mysql import data garbled error how to do, many novices are not very clear about this, in order to help you solve this problem, the following editor will explain in detail for you, people with this need can come to learn, I hope you can gain something.
First, error problem description: use load data infile to import 1 line of data, Chinese is garbled. The character set is specified in load data infile.
Import statement is: load data infile'/ home/mysql/order_data.txt' replace into table test.order_data character set utf8 fields terminated by'| 'enclosed by' lines terminated by'\ n'
Second, problem analysis: 1. The current database character is latin.
Mysql > show variables like 'char%'
+-+
| | Variable_name | Value |
+-+
| | character_set_client | utf8 |
| | character_set_connection | utf8 |
| | character_set_database | latin1 |
| | character_set_filesystem | binary |
| | character_set_results | utf8 |
| | character_set_server | latin1 |
| | character_set_system | utf8 |
| | character_sets_dir | / usr/share/mysql/charsets/ |
+-+
8 rows in set (0.00 sec)
Change the database character set and import it again, still garbled. What's the reason? I have specified the character set in load data file, and the file to be imported is also utf8
Session connection, the database character is also utf8. What on earth is the reason?
It is also found that the table order_data to be imported is the latin1 character set. I changed the table order_data character set to utf8, import or garbled. Later, it was found that the fields of the table were also
Latin1 . Perform the following statement conversion: ALTER TABLE order_data CONVERT TO CHARACTER SET utf8
Finally, the problem is solved. Import is no longer garbled.
Third, problem summary: mysql storage character structure, in addition to looking at the connection character set, connect to the database, the character set used to perform operations, including: session, client, operation results, but also depends on the character set used when saving data: server (global) database library, table table, column column.
Is it helpful for you to read the above content? If you want to know more about the relevant knowledge or read more related articles, please follow the industry information channel, thank you for your support.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.