Chinese garbled solution after MySQL is installed in CentOS
After the MySQL program has been installed in CentOS recently, Chinese exceptions have been found during data import. The solutions can be sorted out for future reference:
The procedure is as follows:
1. After mysql is installed, the default character encoding is latin1.
After logging on to mysql, you can use show variables like '% char %' to view the information, as shown below:
+ ---------------------- + ---------------------
| Variable_name | Value
+ ----------------------- + ---------------------
| Character_set_client | latin1
| Character_set_connection | latin1
| Character_set_database | latin1
| Character_set_filesystem | binary
| Character_set_results | latin1
| Character_set_server | latin1
| Character_set_system | utf8
| Character_sets_dir |/usr/share/mysql/charsets/
+ --------------------- + ----------------------
2. After Entering the/usr/share/mysql directory, copy the my-medium.cnf to/etc
[Root @ bkjia mysql] # cp my-medium.cnf/etc/my. cf
Edit my. cf
[Root @ bkjia mysql] # vim my. cf
Add at the end:
[Client]
Default-character-set = utf8
[Mysqld_safe]
Default-character-set = utf8
[Mysqld]
Default-character-set = utf8
[Mysql]
Default-character-set = utf8
Save and exit.
3. Restart the mysql Service
[Root @ bkjia mysql] #/etc/init. d/mysql restart
4. After logging on to mysql, run show variables like '% char %' again.
+ -------------------------- + ---------------------------- +
| Variable_name | Value |
+ -------------------------- + ---------------------------- +
| Character_set_client | utf8 |
| Character_set_connection | utf8 |
| Character_set_database | latin1 |
| Character_set_filesystem | binary |
| Character_set_results | utf8 |
| Character_set_server | utf8 |
| Character_set_system | utf8 |
| Character_sets_dir |/usr/share/mysql/charsets/|
+ -------------------------- + ---------------------------- +
OK !!
-------------------------------------- Split line --------------------------------------
How to install and configure MySQL5.7.3.0
Install MySQL in Ubuntu 14.04
MySQL authoritative guide (original book version 2nd) Clear Chinese scan PDF
Ubuntu 14.04 LTS install LNMP Nginx \ PHP5 (PHP-FPM) \ MySQL
Build a MySQL Master/Slave server in Ubuntu 14.04
Build a highly available distributed MySQL cluster using Ubuntu 12.04 LTS
Install MySQL5.6 and Python-MySQLdb in the source code of Ubuntu 12.04
MySQL-5.5.38 universal binary Installation
-------------------------------------- Split line --------------------------------------
This article permanently updates the link address: