MySQL can not insert and display Chinese solution in Debian system

Source: Internet
Author: User
Tags join mysql insert mysql view

In a Debian environment, completely solve the problem that MySQL cannot insert and display Chinese

Linux under MySQL insert Chinese display garbled solution

Mysql-uroot-p return Enter password

Enter the MySQL view status as follows:

The default is the client and server are used latin1, so will be garbled.

Solution:

Mysql>user MyDB;

Mysql>alter database mydb Character Set utf8;!

The above mentioned the use of temporary methods to change the database's character set settings, display Chinese, but later found in some systems can not be successful.

For example, I used Debian 7.0, looking for a long time to find a solution for the Debian system,Debian 7.0 tested successfully, others such as modify client and MySQL join default-character-set= UTF8 methods and the like, only apply with 5.5 before the system!

Ultimate solution, once and for all:

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

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

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

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

Join Default-character-set=utf8 under "mysqld"

Notice: Note If you can not start the error after modification try to change the Default-character-set=utf8 to Character_set_server=utf8, just add to the mysqld below. Client doesn't need to add.

Four, #vim/etc/mysql/my.cnf. (after 5.5 system) modify as follows:

[Client]
Default-character-set=utf8

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

Five, restart MySQL (/etc/init.d/mysql stop/etc/init.d/mysql start)

Six, build success, enter MySQL view character set (Mysql>show variables like ' character_set_% ';)


MySQL cannot insert Chinese

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.