Set the default character encoding in mysql to UTF-8

Source: Internet
Author: User
If you set the default character encoding in mysql to UTF-8 and have used Linux, you will know that installing mysql in Linux, especially when using yum for installation, we cannot select the default character encoding method. This is a headache. If you use Chinese characters in a Linux database, Garbled text may cause a headache. Let's talk about Linu today.

If you set the default character encoding in mysql to UTF-8 and have used Linux, you will know that installing mysql in Linux, especially when using yum for installation, we cannot select the default character encoding method. This is a headache. If you use Chinese characters in a Linux database, Garbled text may cause a headache. Let's talk about Linu today.

Set the default character encoding in mysql to UTF-8

If you have used Linux, you will know that you cannot select the default character encoding method when installing mysql in Linux, especially when using yum. This is a headache. If you use Chinese characters in a Linux database, Garbled text may cause a headache. Today, let's talk about how to set the default encoding method in Linux.

1. First, stop the mysql service. You must have the root permission.


service mysqld stop

2. Find my under/etc. cnf file, if not, find the my-medium.cnf file under the support-files folder under the mysql installation directory, copy to/etc/and rename it my. cnf

3. Edit the my. cnf file, add default-character-set = utf8 to its [client] and [mysqld], and save and close the file.

[client]#password= your_passwordport= 3306socket= /tmp/mysql.sockdefault-character-set=utf8# Here follows entries for some specific programs# The MySQL server[mysqld]port= 3306socket= /tmp/mysql.sockskip-external-lockingkey_buffer_size = 16Mmax_allowed_packet = 1Mtable_open_cache = 64sort_buffer_size = 512Knet_buffer_length = 8Kread_buffer_size = 256Kread_rnd_buffer_size = 512Kmyisam_sort_buffer_size = 8Mdefault-character-set=utf8
4. Restart the service.

PS: the setting method is similar in Windows.

Find my. INI file, modify [client] and [mysqld] followed by default-character-set = utf8, if not found, find the my-medium.ini file, copy and rename it my. ini.


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.