Home > Article > Backend Development > sql programming Solution to insert Chinese garbled characters when MYSQL programming under Linux
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 has nothing to do with vim. Then I tried the c# code and used Encoding.UTF8. The .GetString() method was incorrect later.
I was depressed, and suddenly I thought there was something wrong with mysql settings? ? ?
So, sudo nano /etc/mysql/my.cnf
Insert the following red code, default-character-set = utf8, success, no more 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
[mysqld]
#
# *Basic Settings
#
user 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
The above introduces the solution for inserting Chinese garbled characters when MYSQL programming under Linux in sql programming, including the content of sql programming. I hope it will be helpful to friends who are interested in PHP tutorials.