Use the source to install MySQL in Ubuntu9.04. By default, mysqlshell 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 the JDBC connection is used. The solution is as follows (back up data first): Modify/etc/mysql/my. cnfsudogedit/etc/mysql/my. cnf in my. add the following two lines to the [client] and [mysqld] segments in the cnf file:
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:
[Client]
Default-character-set = utf8
[Mysqld]
Default-character-set = utf8
Mysql service needs to be restarted
Disable:
Sudo mysqladmin shutdown-u root-p
Enter the mysql root User Password.
Enable:
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, http://ubuntuone.cn so before this back up data, modify the encoding and then import.