msyql数据库安装时候需要默认编码方式或者使用MySQL Server Instance Config Wizard 配置,
在设置Configure the MySQL Server 5.0 server instance那里的时候选择Manual Selected Default Character Set / Collation 为 UTF8 而不是默认的 LATIN1 在MYSQL里查看得 mysql> \s;
-------------- E:\MySQL\MySQL Server 5.0\bin\mysql.exe Ver 14.12 Distrib 5.0.51a, for Win32 (ia32) Connection id: 2 Current database: Current user: root@localhost SSL: Not in use Using delimiter: ; Server version: 5.0.51a-community-nt MySQL Community Edition (GPL) Protocol version: 10 Connection: localhost via TCP/IP Server characterset: utf8 Db characterset: utf8 Client characterset: utf8 Conn. characterset: utf8 TCP port: 3306 Uptime: 25 sec Threads: 1 Questions: 4 Slow queries: 0 Opens: 12 Flush tables: 1 Open tables: 6 Queries per second avg: 0.160
my.ini文件内容为
[mysql] default-character-set=utf8 # SERVER SECTION # ---------------------------------------------------------------------- # # The following options will be read by the MySQL Server. Make sure that # you have installed the server correctly (see above) so it reads this # file. # [mysqld] # The TCP/IP Port the MySQL Server will listen on port=3306 #Path to installation directory. All paths are usually resolved relative to this. basedir="E:/MySQL/MySQL Server 5.0/" #Path to the database root datadir="E:/MySQL/MySQL Server 5.0/Data/" # 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=utf8 ...........