MySQL Chinese character-set

Source: Internet
Author: User

First: Set parameters in initialization file (MY.CNF)

The default character set for MySQL database is Latin. So it needs to be set in MY.CNF. Like what:

[Email protected] test]# MORE/ETC/MY.CNF

[Mysqld]

Default-character-set=utf8

Then connect to MySQL and view:

mysql> status

Server Characterset:utf8
Db Characterset:utf8
Client characterset:latin1
Conn. characterset:latin1
The second type: Set the client's character set

When you connect to MySQL, you need to add a parameter, such as:

[Email protected] test]# Mysql-uroot-p–default-character-set=utf8

mysql> status

Server Characterset:utf8
Db Characterset:utf8
Client Characterset:utf8
Conn. Characterset:utf8
The third type: Modify the server's environment variable LANG

[Email protected] test]# export Lang=en_us

And then connect to MySQL, you can input Chinese.
Summarize:

The first two methods are mainly to solve the problem of Chinese garbled, the third method is to solve the method can not input Chinese.

MySQL string modified to UTF8 under Debian (reference: Rainysia's Column)

First, go to MySQL (mysql-uroot-p), view the current database character set (status;)

Second, view the current system version (LSB_RELEASE-A)

MySQL cannot insert Chinese

Third, #vim/etc/mysql/my.cnf. (Before 5.5 system) under "client" add
Default-character-set=utf8

Add Default-character-set=utf8 under "Mysqld"

Notice: note
If you can not start the error after modifying the Default-character-set=utf8 change to Character_set_server=utf8, just add to the mysqld below. The client doesn't need to be added.

Iv. #vim/etc/mysql/my.cnf. (after 5.5 system) the following modifications:

[Client]
Default-character-set=utf8


[Mysqld]
Default-storage-engine=innodb
Character-set-server=utf8
Collation-server=utf8_general_ci


V. Restart MySQL (/etc/init.d/mysql stop/etc/init.d/mysql start)

Six, to succeed, into the MySQL view character set (Mysql>show variables like ' character_set_% ';)

MySQL Chinese character-set

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.