Mysql garbled Solution

Source: Internet
Author: User

Mysql garbled Solution
First, enter mysql> show variables like 'Char % 'in mysql editing mode under the command line to view the character set settings of the database.
 

Client, connection, and result are related to the command line client (gbk must be set for the command line client in windows)

Database server system and server-related character sets (the system character set cannot be modified) * In actual development, we recommend that you set the database and server character sets to utf8. After modifying the database server system and server-related character sets, You need to restart mysql to take effect. You can also restart the mysql service, in the command line: stop command: net stop mysql start command: net start mysql
Mysql core configuration file my. ini if linux my. cnf
[Mysql] mainly configures the command line client parameter default-character-set = gbk ---- affects the client, connection, and result
[Mysqld] configuring the server parameter character-set-server = utf8 ----- affects database server
Note: If Windows 7 is used, you can copy the file and put the modification back because of permission issues. (This problem occurs when mysql is installed on disk C)
 

If utf8 has been set for the server character set to create a database data table, the default utf8 ----- the inserted data must not contain garbled characters.
If the server does not set the server character set, the default value is latin1. If the database is created and the specified character set is UTF-8, the table is created and the specified character set is UTF-8 (garbled)
Solution 1: Set the server Character Set and recreate the database and table
Solution 2: jdbc: mysql: // db? UseUnicode = true & characterEncoding = UTF-8 (default transport Character Set utf8/gbk)
 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.