How to solve Chinese garbled characters in MySQL

Source: Internet
Author: User

MySQL Character Set

1. display character sets
Mysqladmin-uroot-proot variables | grep character

| Character_set_client | latin1 |
| Character_set_connection | latin1 |
| Character_set_database | latin1 |
| Character_set_results | latin1 |
| Character_set_server | latin1 |
| Character_set_system | utf8 |
| Character_sets_dir |/usr/local/share/mysql/charsets/|

Database uses latin1 (ISO-8859) by default)


Ii. configuring character sets

1. Configure character sets when creating a database

Create database testxxx default charset = utf8

3. Configure character set during table Creation

Create table 't_ agent '(
'Id' smallint (5) NOT NULL
) Default charset = utf8;

4. Modify Character Set

Windows Platform
In windows, the mysql configuration file is my. ini. Generally, it can be directly added to c: \ windows \ my. ini or c: \ winnt \ my. ini.
Default-character-set = gbk # Or gb2312, big5, utf8
Then restart mysql
Service mysql restart
Or
/Etc/init. d/mysql restart
Or use another method to restart the instance.

[Edit] Unix platform
The mysql configuration file in linux is my. cnf, which is usually/etc/my. cnf. If you cannot find it, run the find command to find it:
Find/-iname my. cnf
Add
Default-character-set = gbk # Or gb2312, big5, utf8
Then restart mysql

3. Configure the sorting Character Set

Myisamchk-r-q -- set-character-set = charset

4. Modify the character set when starting the database

./Mysqld_safe -- character-set-server = utf8 -- skip-character-set-client-handshake -- user = root &

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.