欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  后端开发

Linux下进行MYSQL编程时插入中文乱码的解决方案_PHP教程

程序员文章站 2022-04-11 14:03:44
...
插入中文是乱码,尝试了许多方法,比如我先把vim里设置为:set fileencoding=utf-8不起作用,后来想想也对,和vim没什么关系
然后就尝试c#代码,用Encoding.UTF8.GetString()方法,后来也不对。
我就郁闷了,忽然想起来莫不是mysql的设置问题???
于是,sudo nano /etc/mysql/my.cnf
插入下面红色代码,default-character-set = utf8,成功,不乱码了~~~根本不用什么Encoding.....
# 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 = 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.htmlTechArticle插入中文是乱码,尝试了许多方法,比如我先把vim里设置为:setfileencoding=utf-8不起作用,后来想想也对,和vim没什么关系 然后就尝试c#代码,...