MySql中文不會亂碼的設定
============================================================================
(1).由 MySql 設定
MySql 設定檔(my.ini)內有兩處語系設定改成 UTF8 碼
1.
[mysql]
# default-character-set=latin1 > 原本內定的 , # 只是註解
default-character-set=utf8 > 改為 UTF8 碼
2.
# The default character set that will be used when a new schema or table is
# created and no character set is defined
# default-character-set=latin1 > 原本內定的 , # 只是註解
default-character-set=utf8 > 改為 UTF8 碼
3.MySql 的資料庫及Table,欄位 , 也都要 UTF8
(2).不由 MySql 設定 , 由程式上的連線做設定亦可
1. MySql.Data.MySqlClient.MySqlConnection connmysql = new MySqlConnection("server=192.168.1.77;uid=root;pwd=123456;database=testdatabase;CharSet=utf8");
連線宣告上要做 CharSet=utf8 語系碼的設定
2.MySql 的資料庫及Table,欄位 , 也都要 UTF8 |