MySQL5.6.25 in Ubuntu15.04 does not support Chinese solutions. apt-getinstall is installed instead of mysql installed in the source code package. 1. Modify the mysql configuration file/etc/mysql/conf. d/mysql. cnf adds the following statement below [mysql]: (Note: This file is not configured, only [mysql]) no-auto-rehashdefault-character-set = utf8
MySQL 5.6.25 in Ubuntu 15.04 does not support Chinese solutions. It is installed with apt-get install instead of mysql installed in the source code package.
1. Modify the mysql configuration file
/Etc/mysql/conf. d/mysql. cnf
Add the following statement below [mysql]: (Note: This file is not configured, only [mysql ])
No-auto-rehash
Default-character-set = utf8
/Etc/mysql. conf. d/mysqld. cnf
Add under [mysqld]
Socket =/var/run/mysqld. sock
Port = 3306
Character-set-server = utf8 (here it is server, some previous versions are set)
Restart mysql: sudo/etc/init. d/mysql restart
View Character Set
mysql> show variables like
'%char%'
;
+--------------------------+----------------------------+
| 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/
|
+--------------------------+----------------------------+
8 rows
in
set
(0.00 sec)
After the settings, if the previous database has been created, you can only delete and recreate the database.
-------------------------------------- Split line --------------------------------------
The solution is summarized as follows:
1. Modify the mysql configuration file
/Etc/mysql/conf. d/mysql. cnf
Add the following statement below [mysql:
No-auto-rehash
Default-character-set = utf8
/Etc/mysql. conf. d/mysqld. cnf
Add under [mysqld]
Socket =/var/run/mysqld. sock
Port = 3306
Character-set-server = utf8 and other content, self-comparison, some do not need to add, generally only need to add character-set-server = utf8
At this time, shell enters mysql and runs: show variables like 'character % '. The result is:
Restart mysql: sudo/etc/init. d/mysql restart
Error Code: 1366. Incorrect string value: '\ xE5 \ xBC \ xA0 \ xE4 \ xB8 \ x89' for column 'ename 'at row 1
This is because the character set of the table does not support Chinese characters. Run show create table new_table to view the table creation statement.
Solution: Delete the table and create a new table. The key to supporting Chinese characters lies in the character set selected for table creation.
For more information about Ubuntu, see Ubuntu special page http://www.linuxidc.com/topicnews.aspx? Tid = 2
This article permanently updates the link address: Http://www.linuxidc.com/Linux/2015-09/123236.htm