MySQL sets the default database Encoding

Source: Internet
Author: User

MySQL sets the default database Encoding

If the encoding method is not selected during MySQL installation, the system selects latin1 encoding by default, in the MySQL Console window, enter show variables like 'Char % 'to view the default sequence set of the database system, as shown below:

We can see that the default encoding of the system is Latin1 encoding method, Latin1 is the alias of the ISO-8859-1, some environments write Latin-1. ISO-8859-1 encoding is a single-byte encoding that is backward compatible with ASCII. Chinese encoding is not supported. If you do not specify the encoding method when creating a database or table, the database uses the default encoding method, then, garbled characters will appear when you insert Chinese data. But if we need to manually specify the encoding method every time we create a database or a key table, it will be very troublesome. How can we manually modify the default encoding method of the database?

1. Close the mysql service, manually stop the mysql service in the service, or enter net stop mysql in the cmd window.

2. find my. INI file, if it is for the database initialization, then change the my-default.cof to my. cof, find [mysql] in the file, and add the following two lines to the next line.

Character_set_server = gbk

Init_connect = 'set NAMES gbk'

You can also directly add it to my. ini.

As follows:

3. Save and restart. Check again. We can see that the default encoding of the system has changed.

This article permanently updates the link address:

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.