Some changes in the settings of the mysql5.5 character set (for Chinese garbled characters, you need to set mysq_MySQL

Source: Internet
Author: User
A slight change in the settings of the mysql character set (for Chinese garbled characters, mysql character set needs to be set) does not cause a headache due to character set problems, but also makes a mistake. it is better to save the time and avoid major accidents, alas, it is very necessary to clarify the points:

For example, my work environment is CTR + redhat5 + mysql5.5

When importing SQL statements, you must pay attention to three places: (here we take the UTF-8 character set as an example)

Character set problems:

1. the crt should be changed to UTF-8 xin

2. change the linux character set locale

LANG = en_US.UTF-8

3. in mysql, the client must be:

Mysql>/s

...

Server characterset: utf8

Db characterset: utf8

Client characterset: latin1

Conn. characterset: latin1

...

Mysql> set names utf8; here the character set of the temporary change client is UTF-8, this is caused by historical issues, only temporary change.

Query OK, 0 rows affected (0.00 sec)

Mysql>/s

...

Server characterset: utf8

Db characterset: utf8

Client characterset: utf8

Conn. characterset: utf8

...

In another case, the character set can take effect permanently. the method is as follows:

For Chinese garbled characters, you need to set the mysql character set:

Use the find command to find the cnf file. Remember not to go to my. cnf because it does not necessarily exist, but should look for *. cnf.

# Find/-name '*. cnf'

/Usr/share/doc/MySQL-server-5.5.27/my-huge.cnf

/Usr/share/doc/MySQL-server-5.5.27/my-large.cnf

/Usr/share/doc/MySQL-server-5.5.27/my-medium.cnf

/Usr/share/doc/MySQL-server-5.5.27/my-small.cnf

/Usr/share/doc/MySQL-server-5.5.27/my-innodb-heavy-4G.cnf

/Usr/share/doc/kpathsea-2007/kpathsea_defaults/texmf-kpathsea-defaults.cnf

/Usr/share/mysql/my-huge.cnf.

/Usr/share/mysql/my-large.cnf.

/Usr/share/mysql/my-medium.cnf.

/Usr/share/mysql/my-small.cnf.

/Usr/share/mysql/my-innodb-heavy-4G.cnf.

/Etc/pki/tls/openssl. cnf

Copy one.

# Cp/usr/share/mysql/my-huge.cnf/etc/my. cnf

Open my. cnf and modify the encoding.

# Vi/etc/my. cnf

Below mysql5.5:

Add under [mysqld]

Default-character-set = utf8

Add under [client]

Default-character-set = utf8

Change mysql 5.5:

[Client]

Default-character-set = utf8

[Mysqld]

Character-set-server = utf8

Restart mysql

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.