Modify the mysql5.5 default encoding (the graphical step is modified to utf-8 encoding) _mysql

Source: Internet
Author: User

The default encoding for MySQL databases is not utf-8.

After installing MySQL, start the service and log in, use the show variables command to view the default encoding of the MySQL database:


The character set of database and server, as shown in the figure above, uses latin1 encoding, and does not support Chinese, that is, garbled characters will appear when storing Chinese. The following is the process of modifying the command line to UTF-8 encoding to support Chinese.

(1) Close MySQL service

Copy Code code as follows:

Service MySQL Stop

(2) Modify the/ETC/MYSQL/MY.CNF (default installation path)
Copy Code code as follows:

Vim/etc/mysql/my.cnf

After opening the MY.CNF, add the following two lines to [mysqld] within the file:
Copy Code code as follows:

Character_set_server=utf8
init_connect= ' SET NAMES UTF8 '

(as shown in the screenshot):


Save exit.

(3) Restart the MySQL service

Copy Code code as follows:

Service MySQL Start

At this point, complete the modification of the default encoding, landing MySQL after the use of show variable like '%character% ' to obtain the output effect as follows:


Note

The details of the operation 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.