[Mysql] modifies the default encoding of mysql5.5.

Source: Internet
Author: User
The default encoding of the mysql database is not UTF-8. After mysql is installed, start the service and log on. Run the showvariables command to view the default encoding of the mysql database: latin1 encoding is used for the character sets of the visible database and server, and Chinese characters are not supported, that is, garbled characters appear when you store Chinese characters. The following command line is modified to UTF-8 encoding

The default encoding of the mysql database is not UTF-8. After mysql is installed, start the service and log on. Run the show variables command to view the default encoding of the mysql database. The character set of the visible database and server uses the latin1 encoding method and does not support Chinese characters, that is, garbled characters appear when you store Chinese characters. The following command line is modified to UTF-8 encoding

The default encoding of the mysql database is not UTF-8.

After installing mysql, start the service and log on to the mysql database. Run the show variables command to view the default encoding of the mysql database:


The character set of the visible database and server uses the latin1 encoding mode. Chinese characters are not supported, that is, garbled characters appear when storing Chinese characters. The following is the process of modifying the command line to UTF-8 encoding to support Chinese characters.


(1) disable the mysql Service

service mysql stop


(2) Modify/etc/mysql/my. cnf (default installation path)

vim /etc/mysql/my.cnf

After opening my. cnf, add the following two lines under [mysqld] in the file:

character_set_server=utf8init_connect='SET NAMES utf8'

(As shown in ):


Save and exit.


(3) restart the mysql Service

service mysql start

Now, the default encoding is modified. log on to mysql and use show variable like '% character %' again to obtain the following output:



Note

The specific operations and output are as follows:

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.