MySQL預設為「latin1」時,怎麼辦......?
以下為我大學時,所使用的解決法:
1. 在Linux下,下「mysql」指令
2. 用mysql語法對sql下指令,「\s」
3. 會顯示如下:
--------------
mysql Ver 14.12 Distrib 5.0.26, for pc-linux-gnu (i686) using readline 5.0
Connection id: 3
Current database:
Current user: root@localhost
SSL: Not in use
Current pager: stdout
Using outfile: ''
Using delimiter: ;
Server version: 5.0.26-standard
Protocol version: 10
Connection: Localhost via UNIX socket
Server characterset: latin1
Db characterset: latin1
Client characterset: latin1
Conn. characterset: latin1
UNIX socket: /var/lib/mysql/mysql.sock
Uptime: 59 min 53 sec
Threads: 1 Questions: 2062 Slow queries: 0 Opens: 30 Flush tables: 1 Open tables: 15 Queries per second avg: 0.574
--------------
4. 再將「Server characterset」、「Db characterset」、「Client characterset」、「Conn. characterset」的"latin1"改成"big5"或"utf8",如下
--------------
mysql Ver 14.12 Distrib 5.0.18, for redhat-linux-gnu (i386) using readline 5.0
Connection id: 4
Current database: mydb
Current user: root@localhost
SSL: Not in use
Current pager: stdout
Using outfile: ''
Using delimiter: ;
Server version: 5.0.18
Protocol version: 10
Connection: Localhost via UNIX socket
Server characterset: utf8
Db characterset: utf8
Client characterset: utf8
Conn. characterset: utf8
UNIX socket: /var/lib/mysql/mysql.sock
Uptime: 17 min 6 sec
Threads: 2 Questions: 3296 Slow queries: 0 Opens: 18 Flush tables: 1 Open tables: 39 Queries per second avg: 3.212
--------------
5. 在
Windowss系統的C:\WINDOWS\my.ini
或
Linux系統的/etc/my.cnf
加入以下的語法:
[mysqld]
character-set-server=utf8
default-collation=utf8_unicode_ci
[mysql]
default-character-set=utf8
以上的語法意思如下
[mysqld]內的utf8會改到「Server characterset」、「Db characterset」的欄位
[mysql]內的utf8會改到「Client characterset」、「Conn. characterset」的欄位
留言列表