Mysql Chinese garbled

Source: Internet
Author: User

Mysql Chinese garbled
Although mysql is installed on the computer, I have never studied the problem of modifying the encoding. I usually use Pinyin instead of Chinese characters, because I am doing some simple syntax exercises, I am not very concerned about this issue.
My database already has some garbled data tables, and Baidu has some methods on the Internet, such:

Mysql> set names utf8; # modify the encoding to utf8
These are useless and the results are garbled. There are also some encoding states in the database:
mysql> show variables like '%character%';+--------------------------+----------------------------+| Variable_name            | Value                      |+--------------------------+----------------------------+| character_set_client     | utf8                       || character_set_connection | utf8                       || character_set_database   | latin1                     || character_set_filesystem | binary                     || character_set_results    | utf8                       || character_set_server     | latin1                     || character_set_system     | utf8                       || character_sets_dir       | /usr/share/mysql/charsets/ |+--------------------------+----------------------------+8 rows in set (0.00 sec)mysql>
Then, use a command similar to the following to change the code that is not UTF-8 encoded to utf8.
mysql> set character_set_database=utf8;
It seems that this method will be restored after being restarted. Later, I saw another method, which was completed by modifying the configuration file. After I tried this method, it will not be restored after restart.
First, shut down the mysql service (mysql stop is used on the Internet. I tried it and couldn't use it)
buzhidao@nongfushanquan-K55VD:~$ sudo /etc/init.d/mysql stop
Then modify the configuration file.
buzhidao@nongfushanquan-K55VD:~$ sudo gedit /etc/mysql/my.cnf
Then add the following content (do not include any extra space at the end. I accidentally typed a space at the end and the result did not take effect ):
character_set_server=utf8  init_connect='SET NAMES utf8'

Finally, open the mysql service (mysql start is used on the Internet. I tried it and cannot use it)

buzhidao@nongfushanquan-K55VD:~$ sudo /etc/init.d/mysql start

As a result, I started to create a table and found that Chinese characters are still garbled. I checked the table creation syntax and found that the default encoding is not utf8,

Then I create another table. This time I specify the table encoding and the Chinese part can be displayed normally. <喎?http: www.bkjia.com kf ware vc " target="_blank" class="keylink"> VcD4KPHA + pgltzybzcm9 "http://www.2cto.com/uploadfile/Collfiles/20150514/2015051410110621.png" height = "457" width = "349" align = "middle" alt = "">


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.