How to set default character encoding as utf-8_MySQL-mysql in mysql

Source: Internet
Author: User
Set the default character encoding in mysql to UTF-8 bitsCN.com.

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.

[plain] 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.

[plain] [client]  #password   = your_password  port        = 3306  socket      = /tmp/mysql.sock  default-character-set=utf8    # Here follows entries for some specific programs    # The MySQL server  [mysqld]  port        = 3306  socket      = /tmp/mysql.sock  skip-external-locking  key_buffer_size = 16M  max_allowed_packet = 1M  table_open_cache = 64  sort_buffer_size = 512K  net_buffer_length = 8K  read_buffer_size = 256K  read_rnd_buffer_size = 512K  myisam_sort_buffer_size = 8M  default-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.

BitsCN.com

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.