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 this because MySQL Default

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 this because MySQL Default

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, the default Character Set of MySQL is latin1 (ISO_8859_1) and not utf8.

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 _ % ';

Related reading:

Ubuntu 12.04 MySQL cannot be started after UTF-8 is changed

Using mysqldump in Linux to back up a MySQL database as an SQL File

Use mysqldump in Linux to regularly back up MySQL Databases

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.