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