MySQL Database garbled solution method

Source: Internet
Author: User

MySQL Database garbled solution method

A principle of solving garbled problems: Access systems use consistent coding rules.

Use MySQL's native command line more, so you can do more things.

?

The first step:

Identify the encoding your application needs to use

Java's default encoding is to follow the system, some of which are default Unicode, and you can use String Defaultcharsetname=charset.defaultcharset () in Java. displayName (); Display encoding.

Step Two:

Confirm and set the encoding of the MySQL database

1. Display coding, simple Method command is: status; or mysql> SHOW VARIABLES like ' character% ';

mysql> status

--------------

C:\Program Files (x86) \mysql\mysql Server 5.0\bin\mysql.exe Ver 14.12 distrib 5

.0.67, for Win32 (IA32)

Connection Id:3

Current database:

Current User: [email protected]

Ssl:not in use

Using delimiter:;

Server version:5.0.67-community-nt MySQL Community Edition (GPL)

Protocol version:10

Connection:localhost via TCP/IP

Server CHARACTERSET:GBK

Db CHARACTERSET:GBK

Client CHARACTERSET:GBK

Conn. Characterset:gbk

TCP port:3306

Uptime:12 min-Sec

Threads:3 questions:32 Slow queries:0 opens:32 Flush tables:1 Open tab

Les:26 Queries per second avg:0.041

--------------

2. Modify the Encoding

Make sure that all is set to the required characters, here we take UTF8 as an example.

2.1 The changes in the My.ini configuration file (which is invalidated after the restart service using Set settings on the command line), the following changes are required for each label:

C:\Program Files (x86) \mysql\mysql Server 5.0\my.ini

[Client]

Default-character-set=utf8

[MySQL]

Default-character-set=utf8

[Mysqld]

Default-character-set=utf8

2.2 Server CharacterSet is not able to be modified in the configuration file, but also do not have to reinstall the database, only need to restart the configuration program MySQLInstanceConfig.exe.

C:\Program Files (x86) \mysql\mysql Server 5.0\bin\mysqlinstanceconfig.exe

Choose UTF8 where you choose the code, and the default is Latin1. Selected two or third, the second default is UTF8, the third hand-selected UTF8.

Step Three:

Restart MySQL Service

CMD under:

net stop MySQL

net start MySQL

mysql> use qba_db;

Database changed

mysql> status;

--------------

C:\Program Files (x86) \mysql\mysql Server 5.0\bin\mysql.exe Ver 14.12 distrib 5

.0.67, for Win32 (IA32)

Connection id:168

Current database:qba_db

Current User: [email protected]

Ssl:not in use

Using delimiter:;

Server version:5.0.67-community-nt MySQL Community Edition (GPL)

Protocol version:10

Connection:localhost via TCP/IP

Server Characterset:utf8

Db Characterset:utf8

Client Characterset:utf8

Conn. Characterset:utf8

TCP port:3306

Uptime:20 Days Hours 4 min sec

Threads:5 questions:3224 Slow queries:0 opens:151 Flush tables:1 Open

tables:0 Queries per second avg:0.002

--------------

MySQL Database garbled solution method

Related Article

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.