MySQL encoding settings

Source: Internet
Author: User

Database encoding

The database uses a feature code to save data, such as Latin, Big5, GB2312, UTF8, etc., different languages generally use different encoding to save

Coding mainly affects the following two aspects:

1. The amount of space occupied by the database to hold the same content.

2. Database and Client communication


The default encoding for the MySQL database is:

Chrarcter Set:latin 1

Collation:latin 1_swedish_ci


You can view the encoding supported by MySQL using the following command:

Show character set;

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/5B/73/wKiom1UJJeOzK6tdAAaQm_XKkBU207.jpg "title=" 66666666.png "alt=" Wkiom1ujjeozk6tdaaaqm_xkkbu207.jpg "/>

The following command allows you to view the encoding currently used by MySQL:

Show variables like ' character_set% ';

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/5B/6E/wKioL1UJKD7DJELfAAFCmOD_Rks605.jpg "title=" 7777777777777.png "alt=" Wkiol1ujkd7djelfaafcmod_rks605.jpg "/>

Or use this command to show variables like ' collation% ';


We define the database encoding when we create the database.

mysql> CREATE DATABASE LC//creation of a DB LC

--Default character Set UTF8//define encoding UTF8

--Default collate utf8_general_ci; UTF8 the following format

Query OK, 1 row Affected (0.00 sec)


I am now use LC

Looking at the code of this data, we find that the database code of the database LC is UTF8.

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/5B/6E/wKioL1UJKM-Afhx2AAFZiv9qzx0043.jpg "title=" 888888888888888888.png "alt=" Wkiol1ujkm-afhx2aafziv9qzx0043.jpg "/>


You can also modify the encoding of a database by using the following command

ALTER DATABASE Linuxcast character set UTF8 collate utf8_general_ci;


Modify MySQL default encoding

[Client]

Default-character-set=utf8

[MySQL]

Default-character-set=utf8

[Mysqld]

Default-character-set =utf8

Collation-server=utf8_unicode_ci

init-connect= ' SET NAMES UTF8 '

Character-set-server=utf8


This article is from "think one or two" blog, please be sure to keep this source http://972010.blog.51cto.com/962010/1621845

MySQL encoding settings

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.