The solution is as follows:
| The code is as follows |
Copy Code |
#vi/etc/my.cnf |
Add the following coding settings in the appropriate place
| The code is as follows |
Copy Code |
[Mysqld] Default-character-set=gbk [Mysql.server] Default-character-set=gbk [Mysqld_safe] Default-character-set=gbk [Client] Default-character-set=gbk [MySQL] Default-character-set=gbk |
Restart MySQL.
If you don't know where MySQL is, run
| The code is as follows |
Copy Code |
| #whereis MySQL |
You can find where MySQL is installed.
If you want to check if the settings are successful, you can run the following command:
| The code is as follows |
Copy Code |
# mysql-u Root-proot Welcome to the MySQL Monitor. Commands End With; or G. Your MySQL Connection ID is 2 to server version:5.0.22 Type ' help, ' or ' h ' for help. Type ' C ' to clear the buffer. Mysql> Show variables like '%char% '; +--------------------------+----------------------------+ | variable_name | Value | +--------------------------+----------------------------+ | character_set_client | GBK | | character_set_connection | GBK | | Character_set_database | GBK | | Character_set_filesystem | binary | | Character_set_results | GBK | | Character_set_server | GBK | | Character_set_system | UTF8 | | Character_sets_dir | /usr/share/mysql/charsets/| +--------------------------+----------------------------+ 8 rows in Set (0.00 sec) |
The above has shown that the encoding settings have been successful.