插入中文是亂碼,試了許多方法,例如我先把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]
= 0
[mysqld]
#
# * Basic Settings
#
user = mysql
pid-my = mysql
pid-my = /var/run/mysqld/ mysqld.sock
default-character-set = utf8
port = 3306 tmpdir = /tmp
language = / usr/share/mysql/english
skip-external-locking
以上就介紹了sql程式設計 Linux下進行MYSQL程式設計時插入中文亂碼的解決方案,包含了sql程式設計方面的內容,希望對PHP教學有興趣的朋友有所幫助。