插入中文是亂碼,嘗試了許多方法,比如我先把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