Home > Backend Development > PHP Tutorial > Solution to insert Chinese garbled characters when programming MYSQL under Linux_PHP tutorial

Solution to insert Chinese garbled characters when programming MYSQL under Linux_PHP tutorial

WBOY
Release: 2016-07-21 15:56:52
Original
1086 people have browsed it

Inserting Chinese characters is garbled. I tried many methods. For example, I first set vim to: set fileencoding=utf-8 but it didn’t work. Then I thought about it and it was right. It has nothing to do with vim
Then I tried c# code and used Encoding The .UTF8.GetString() method was also incorrect later.
I was depressed, and suddenly I thought it was a problem with mysql settings? ? ?
So, sudo nano /etc/mysql/my.cnf
Insert the following red code, default-character-set = utf8, success, no garbled characters~~~No need for encoding at all.....
# This was formally known as [safe_mysqld]. Both versions are currently parsed.
[mysqld_safe]
socket = /var/run/mysqld/mysqld.sock
nice = 0
[mys qld]
#
# * Basic Settings
#
user = mysql
pid-file = /var/run/mysqld/mysqld.pid
socket = /var/run/mysqld/ mysqld.sock
default-character-set = utf8
port = 3306
basedir = /usr
datadir = /var/lib/mysql
tmpdir = /tmp
language = / usr/share/mysql/english
skip-external-locking

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/318002.htmlTechArticleInserting Chinese is garbled. I have tried many methods. For example, I first set vim to:setfileencoding=utf-8 It didn’t work, but then I thought it was right. It had nothing to do with vim, so I tried the c# code...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template