Modify MySQL characters in Ubuntu to UTF-8

Source: Internet
Author: User
First of all, this is the default MySQL character set () In Ubuntu. It is garbled question mark when entering Chinese Characters in Java to the database. MySQL does not recognize it because the default Character Set of MySQL is latin1 (ISO_8859_1) it is not a UTF-8 character set. Modification Method: 1. open my. modify the cnf file (note that the MySQL version is later than 5.5, and the following versions should also be common. This is not tested, but it is absolutely feasible to use the cnf File above 5.5) sudogedit

First of all, this is the default MySQL character set () In Ubuntu. It is garbled question mark when entering Chinese Characters in Java to the database. MySQL does not recognize it because the default Character Set of MySQL is latin1 (ISO_8859_1) it is not a UTF-8 character set.

Modification method:

1. Open the my. cnf file and modify it. (Note that the MySQL version is later than MySQL 5.5 and the following versions are also common. The MySQL version has not been tested, but is absolutely feasible in MySQL 5.5 or later versions)

Sudo gedit/etc/mysql/my. cnf

2. add the following code under [mysqld] (for Versions later than 5.5, the default Character Set setting of [mysqld] is an abandoned parameter, which can be used. For details, refer to the corresponding version manual)

Character-set-server = utf8

Collation-server = utf8_general_ci

Skip-character-set-client-handshake

3. Exit and restart the mysql service.

Sudo service mysql restart

4. Go to mysql to view the character set

Mysql> show variables like 'collation _ % ';

Mysql> show variables like 'character _ set _ % ';

Reading:

Ubuntu 12.04 MySQL UTF-8 cannot start the http://www.linuxidc.com/Linux/2012-06/63362.htm

Linux Through mysqldump backup MySQL database into SQL file http://www.linuxidc.com/Linux/2013-02/79793.htm

Using mysqldump in Linux to regularly back up MySQL database http://www.linuxidc.com/Linux/2012-03/56063.htm

For more information about Ubuntu, see Ubuntu special page http://www.linuxidc.com/topicnews.aspx? Tid = 2

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.