To save the trouble in the future, we can modify the mysql garbled characters in the configuration file under RHEL6.3. My mysql configuration file is etcmy. cnf
To save the trouble in the future, we can modify the mysql garbled characters in the configuration file under RHEL6.3. My mysql configuration file is/etc/my. cnf
To save the trouble in the future, we can modify mysql garbled characters in the configuration file under RHEL6.3. My mysql configuration file is/etc/my. cnf
1. First find [mysqld] in the configuration file and add the following line:
[Mysqld]
Character_set_server = utf8
2. Find the [mysql] option. I do not have this option here, and some do not need to be added. I added the following:
[Mysql]
Default-character-set = utf8
3. Restart the mysql service.
[Root @ mysql ~] #/Etc/init. d/mysqld restart
Stop mysqld: [OK]
Starting mysqld: [OK]
4. Go to mysql to view the Encoding
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/|
+ -------------------------- + ---------------------------- +
8 rows in set (0.00 sec)
5. If you still cannot set it manually, the setting command is as follows:
Mysql> SET character_set_client = utf8;
Mysql> SET character_set_connection = utf8;
Mysql> SET character_set_database = utf8;
Mysql> SET character_set_results = utf8;
Mysql> SET character_set_server = utf8;
Mysql> SET collation_connection = utf8;
Mysql> SET collation_database = utf8;
Mysql> SET collation_server = utf8;
Related reading:
Solve MySQL garbled characters in CentOS (Linux)
Solution to MySQL garbled characters under Fedora 15