Troubleshooting of MySQL Chinese garbled characters in Ubuntu 9.04

Source: Internet
Author: User

MySQL is installed with the source in Ubuntu 9.04. By default, mysql shell is used to log on to create a database, create a table, and insert Chinese data. The select statement is used to identify Chinese, but garbled characters are displayed when JDBC is used. The solution is as follows (back up data first ):

Modify/etc/mysql/my. cnf
Sudo gedit/etc/mysql/my. cnf

Add the following two lines to the [client] and [mysqld] segments in the my. cnf file:
Default-character-set = utf8
Default-character-set = utf8

Mysql service needs to be restarted
Sudo mysqladmin shutdown-u root-p
Enter the mysql root User Password.
Sudo mysqld_safe-user = mysql &

Check the current mysql encoding.
Sudo mysql-u root-p

Mysql> show variables like 'character % ';
+ -------------------------- + ---------------------------- +
| 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/|
+ -------------------------- + ---------------------------- +

Now, both mysql shell and JDBC can display Chinese characters normally. But the previous data is still not good, so before this back up data, modify the encoding and then import.

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: 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.