How to solve Chinese garbled MySQL installation in CentOS 6.5

Source: Internet
Author: User

How to solve Chinese garbled MySQL installation in CentOS 6.5

No matter whether it is Linux or Windows, new users may encounter Chinese characters and garbled characters After MySQL service is installed. Today I installed CentOS 6.5 and encountered this problem. Now I have solved the problem and shared some experiences.

1. Install mysql first. I am afraid of trouble .. So I installed all of them, no matter how many dependencies there are, it's easy.

Yum install-y mysql-server mysql-devel

2. After the installation is complete, start and check what the situation is.

Service mysqld start

3. No problem. Set the root password. At first, the root account has no password, so I set the password to 123456 directly.

Mysqladmin-u root password '123'

4. log on to mysql to see what the situation is.

Mysql-u root-p

5. Check the mysql encoding and find that utf8 and Latin are not all found, which is the root cause of Chinese garbled characters.

Show variables like 'character % ';

6. Close the mysql service and start modifying the my. cnf file.

Service mysqld stop
Vi/etc/my. cnf

7. After reading many versions of my. cnf modification methods on the network, I simply changed them to utf8, and my. cnf file is like this.

[Mysqld]
Default-character-set = utf8 # I added this
Character_set_server = utf8 # I added this
Init_connect = 'set NAMES utf8'
Datadir =/var/lib/mysql
Socket =/var/lib/mysql. sock
User = mysql
Symbolic-links = 0
 
[Mysqld_safe]
Default-character-set = utf8 # I added this
Log-error =/var/log/mysqld. log
Pid-file =/var/run/mysqld. pid
 
[Client]
Default-character-set = utf8 # I added this
 
[Mysql. server]
Default-character-set = utf8 # I added this
 
[Mysql]
Default-character-set = utf8 # I added this
 

8. After modifying the my. cnf file, you must restart the mysql service. This is required.

Service mysqld restart
 

9. Check that the encoding is changed to utf8 in mysql, except that character_set_filesystem is binary. I don't need to explain why.

10. If Garbled text is found, it may be your system code or your program writing. Mom no longer needs to worry about my learning.

Solve MySQL garbled characters in CentOS (Linux)

MySQL garbled problem Ultimate Guide

Solve MySQL garbled characters in CentOS (Linux)

Deep Analysis of MySQL garbled Problem

How to solve the MySQL garbled Problem

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.