In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly introduces the relevant knowledge of "how to do garbled code after importing data into MySQL database". The editor shows you the operation process through an actual case. The method of operation is simple and fast, and it is practical. I hope that this article "how to do garbled code after importing data into MySQL database" can help you solve the problem.
When importing data, there are several aspects that affect the encoding of the MySQL database.
Coding settings during installation
The default installation code for MySQL is latin1. It is best to choose utf8 or utf8mb4 when installing. It should be noted that the coding of MySQL is divided into two parts: the client side (the command line client) and the server side.
Server-side coding refers to the coding of the database server itself, that is, the default encoding of the database when the database is created.
Client encoding refers to the encoding used when using a command line client to connect to the database. For example, when you enter the mysql command on the command line to connect to the database, you are using the MySQL command line client.
Create encoding settings for the database
When you create a database, you can specify the database encoding. This is the final step in determining the database encoding, and the encoding set at installation is only the default encoding, that is, when the database is created, if no encoding is specified, the database default encoding is used.
Encoding settings for connecting to the database
Entering the mysql command on the command line to connect to the database (including importing data using the source command) will connect to the database using the encoding settings of the MySQL client. When using other MySQL clients to execute sql files directly (such as Navicat's run SQL File function), it is also possible to use the encoding of the MySQL client.
Encoding of database script files
The file format created in Windows is generally GBK-encoded. The database script file for Jspxcms uses UTF-8 encoding.
How to import to avoid garbled code
In order to ensure that the imported data is not random, it is necessary to do three points: the database is encoded as UTF-8, the client is encoded as UTF-8, and the database script file is encoded as UTF-8.
Among them, the database file of Jspxcms itself is UTF-8 coding, and the database coding can be selected as UTF-8 coding when creating the database. These two conditions are easy to achieve, but the MySQL client code needs to be set during installation, which is often easy to ignore and difficult to modify after installation (need to modify the MySQL configuration file and restart MySQL), which is the main source of garbled code. Even if you are using a visual client, it is possible to use MySQL client encoding if you directly choose to execute the SQL file.
Therefore, the best way to avoid garbled code is to open the sql script file on the premise of confirming that the database code is UTF-8, and copy the contents of the file to the MySQL visualization client for execution (such as Navicat's query window).
The data in the database is not garbled, while the data displayed on the web page is garbled.
This situation is usually caused by the newer version of the MySQL database and the older MySQL driver, such as using MySQL5.7, while the lower version of the MySQL driver (such as mysql-connector-java-5.1.24.jar, located in the / WEB-INF/lib directory) can be solved by using a new version of the database driver (such as mysql-connector-java-5.1.41.jar).
On the "MySQL database import data is garbled how to do" content introduced here, thank you for reading. If you want to know more about the industry, you can follow the industry information channel. The editor will update different knowledge points for you every day.
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.