Chinese garbled solution after MySQL is installed in CentOS

Source: Internet
Author: User

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:

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.