Mysql -- set the MySQL character set to utf8 and mysql -- ubuntuutf8 in Ubuntu

Source: Internet
Author: User

Mysql -- set the MySQL character set to utf8 and mysql -- ubuntuutf8 in Ubuntu

1. mysql configuration file address
/Etc/mysql/my. cnf

 

2. Add the following code below [mysqld]
[Mysqld]
Init_connect = 'set collation_connection = utf8_unicode_ci'
Init_connect = 'set NAMES utf8'
Character-set-server = utf8
Collation-server = utf8_unicode_ci
Skip-character-set-client-handshake

 

3. Restart the mysql service.
Sudo service mysql restart

 

4. Check whether the character set is updated to utf8.
Enter mysql, mysql-u root-p, enter show variables like '% character %' to view the character set
+ -------------------------- + ---------------------------- +
| Variable_name | Value |
+ -------------------------- + ---------------------------- +
| Character_set_client | utf8 |
| Character_set_connection | utf8 |
| Character_set_database | utf8 |
| Character_set_filesystem | binary |
| Character_set_results | utf8 |
| Character_set_server | utf8 |
| Character_set_system | utf8 |
| Character_sets_dir |/usr/share/mysql/charsets/|
+ -------------------------- + ---------------------------- +

 

Note: The character_set_database value of the database that has been created before the character set is modified will not change, and Chinese data inserted into the database will still display garbled characters, therefore, it is best to change the character set to utf8 after MySQL is installed. Otherwise, subsequent modifications will be troublesome.

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.