1. log On As root and enter the command sudogedit/etc/mysql/my on the terminal. cnf find [client] in the open file and add default-character-set = utf8 to find [mysqld_safe]. Add default-character-set = utf8 1 below. log On As root and enter the command sudo gedit/etc/mysql/my on the terminal. cnf is in the opened file
Find the [client] and add it below
Default-character-set = utf8
Find [mysqld_safe] and add it below
Default-character-set = utf8
Find [mysqld] and add it below
Default-character-set = utf8
Init_connect = 'set NAMES utf8'
Find [mysql] and add
Default-character-set = utf8
2. Restart the mysql command to make the modification take effect.
Stop command:Sudo mysqladmin shutdown-u root-p
Enable command:Sudo/etc/init. d/mysql restart
Or:Sudo mysqld_safe-user = mysql &
3. view the current mysql Encoding
Enter the mysql command: sudo mysql-u root-p
Run the show variables like 'character % 'command to check the mysql character set ';
+ -------------------------- + ---------------------------- +
| 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/|
+ -------------------------- + ---------------------------- +
4. The original database and table cannot take effect, but the newly created database and table can display Chinese characters normally!