MySQL collation·½·¨
ÎÊÌâÊÇÕâÑùµÄ£º
Ò»ÕÅtestµÄ±í£¬×Ö·û¼¯²ÉÓõÄlatin1¡£
select to_id from test where to_id='cnÏó_Íõ';
+---------------+
| to_id |
+---------------+
| cnÌÕ_ÌÕ |
| cnÏó_Íõ |
+---------------+
2 rows in set (0.00 sec)
È¡cnÏó_ÍõµÄÊý¾Ý,¾ÓÈ»°ÑcnÌÕ_ÌÕµÄÊý¾ÝҲȡ»ØÀ´ÁË¡£
ÕâÏÔÈ»ÊDz»ÔÊÐíµÄ¡£
²é¿´ËüÃǵıàÂ룺
(root@im_offlog1a)[test]> select hex('cnÌÕ_ÌÕ');
+----------------+
| hex('cnÌÕ_ÌÕ') |
+----------------+
| 636ECCD55FCCD5 |
+----------------+
1 row in set (0.00 sec)
(root@im_offlog1a)[test]> select hex('cnÏó_Íõ');
+----------------+
| hex('cnÏó_Íõ') |
+----------------+
| 636ECFF35FCDF5 |
+----------------+
1 row in set (0.00 sec)
±àÂëµÄÈ·ÊDz»Ò»ÑùµÄ£¬µ«ÊÇΪʲômysql»áÈÏΪÕâÁ½Ìõ¼Ç¼ÊÇÒ»ÑùµÄÄØ£¿
Ò»¿ªÊ¼ÎÒÃǾͰÑÎÊÌⶨλÓÚcollationÒýÆðµÄÎÊÌâ¡£
show variables²é¿´
| collation_connection | latin1_swedish_ci
| collation_database | latin1_swedish_ci
| collation_server | latin1_swedish_ci
ÊÖ¹¤°ÑÕâЩ²ÎÊýÐÞ¸ÄΪlatin1_bin£¬½á¹û¾ÓȻһÑù¡£ÕâϸоõÕæÊÇÆæ¹ÖÁË¡£
ÕâÀïÏȽâÊÍÒ»ÏÂmysql collationµÄÃüÃû¹æÔò£º
ËüÃÇÒÔÆäÏà¹ØµÄ×Ö·û¼¯Ãû¿ªÊ¼£¬Í¨³£°üÀ¨Ò»¸öÓïÑÔÃû£¬²¢ÇÒÒÔ_ci£¨´óСд²»Ãô¸Ð£©¡¢_cs£¨´óСдÃô¸Ð£©»ò_bin£¨¶þÔª£©½áÊø
±ÈÈçlatin1×Ö·û¼¯ÓÐÒÔϼ¸ÖÖУÕý¹æÔò£º
У¶Ô¹æÔò º¬Òå
latin1_german1_ci µÂ¹úDIN-1
latin1_swedish_ci Èðµä/·ÒÀ¼
latin1_danish_ci µ¤Âó/ŲÍþ
latin1_german2_ci µÂ¹ú DIN-2
latin1_bin ·ûºÏlatin1±àÂëµÄ¶þ½øÖÆ
latin1_general_ci ¶àÖÖÓïÑÔ(Î÷Å·)
latin1_general_cs ¶àÖÖÓïÑÔ(Î÷Å·ISO),´óСдÃô¸Ð
latin1_spanish_ci ÏÖ´úÎ÷°àÑÀ
×îºóÎÒÃǽ«±í¸ñÖؽ¨£¬ÊÖ¹¤Ö¸¶¨±í¸ñ¼¶±ðµÄcollationΪlatin1_bin¡£
Õâ¸öÎÊÌâ¾ÍµÃµ½Á˽â¾ö¡£
ÄÇôÎÊÌâÓÖÀ´ÁË£¬ÎªÊ²Ã´ÎÒÇ°ÃæÊÖ¹¤²âÊÔlatin1_binʱ²»ÉúЧÄØ£¿
ÔÀ´MySQL°´ÕÕÏÂÃæµÄ·½Ê½Ñ¡Ôñ±í×Ö·û¼¯ºÍ У¶Ô¹æÔò£º
Èç¹ûÖ¸¶¨ÁËCHARACTER SET XºÍCOLLATE Y£¬ÄÇô²ÉÓÃCHARACTER SET XºÍCOLLATE Y¡£
Èç¹ûÖ¸¶¨ÁËCHARACTER SET X¶øûÓÐÖ¸¶¨COLLATE Y£¬ÄÇô²ÉÓÃCHARACTER SET XºÍCHARACTER SET XµÄĬÈÏУ¶Ô¹æÔò¡£
·ñÔò£¬²ÉÓ÷þÎñÆ÷×Ö·û¼¯ºÍ·þÎñÆ÷У¶Ô¹æÔò¡£
¶øÎÒÃÇÔÚ½¨±íµÄʱºòÖ¸¶¨ÁËcharacter set£¬ËùÒÔËüÓÀÔ¶ÊDzÉÓöÔÓ¦µÄĬÈϵÄУ
Ïà¹ØÎĵµ£º
ÎÊÌ⣺
1¡¢Êý¾Ý¿âĬÈϵÄ×Ö·û¼¯ÉèÖÃΪUTF-8£»
2¡¢Í¨¹ýibatis¶ÁдÊý¾ÝÖÐÎÄÕý³££»
3¡¢µ«ÊÇÓÃwindowsÃüÁîÐÐÖ´ÐÐselectÓï¾äÖÐÎÄÏÔʾÂÒÂë¡£
½â¾ö£º
Êý¾Ý¿âÓû§µÇ¼ʱ²ÎÊýÉ趨×Ö·û¼¯£º
mysql --default-character-set=gb2312 -u ̞ -p
£¨¹À¼ÆºÍwindowsµÄcmdÃüÁîÐÐÓйأ© ......
Ê×ÏÈ°²×°phpMyadmin
[root@aladdin phpMyAdmin]# uname -a
Linux aladdin.leadtek.com.cn 2.6.32.11-99.fc12.i686.PAE #1 SMP Mon Apr 5 16:15:03 EDT 2010 i686 i686 i386 GNU/Linux
[root@aladdin phpMyAdmin]# yum info phpmyadmin
Loaded plugins: presto, refresh-packagekit
Installed Packages
Name &nbs ......
±¾´Î°²×°µÄϵͳƽ̨Ϊredhat 5
Ò»¡¢Ê¹ÓÃRPM°ü½øÐа²×°
Ê×ÏÈ¿ÉÒÔ´Ó°²×°¹âÅÌÖлòÕßµ½mysqlµÄÍøÕ¾ÉÏÏÂÔضÔÓ¦°æ±¾µÄrpm°üÈçÏ£º
MySQL-server-community-5.1.38-0.rhel5.i386.rpm
MySQL-client-community-5.1.38-0.rhel5.i386.rpm
½Ó×ÅÎÒÃÇ¿ÉÒÔʹÓÃrpmÃüÁî½øÐа²×°£º
rpm -ivh MySQL ......
ÓÉÓÚÇ°¶Îʱ¼äÒªÓÃpowerdesignerÉè¼ÆÊý¾Ý¿â£¬¿ÉÊý¾Ý¿âÉè¼ÆºÃºóºÃµ¼ÈëMysQLʱÐèÒªODBCÁ¬½Ó£¬¶øMysQL5.0ÒÔÉϵľùÒªÐÞ¸ÄÃÜÂ루ÎÒÔÚÍøÉϲé¹ý£©£¬°´ËûÃǵÄÒâ˼ÐÞ¸ÄÁËrootÃÜÂ룬½á¹ûÊÇÖ±½Ó½ø²»ÁËMysQLÁË£¬ÎÒÄǸöÓôÃÆ£¬ÔÚÍøÉϲéÕÒ×ÊÁÏ£¬Ò²°´ËûÃǵķ½·¨×öÁË£¬¿É»¹ÊDz»ÐУ¨±¾È˶Ôdos²»Ê죩¡£µ«×îÖÕ»¹ÊÇ¿ÉÒÔÁË£¬ÏÂÃæ˵ϾßÌå·½·¨
1¡¢w ......
ÎÒÔÚmysql ÃüÁîÐÐÕâ¸öϵÁÐÀï½éÉܹýÓÐÌõ¼þ²éѯ£¬ËüÓõ½WHERE×Ӿ䡣µ«ÊÇÓÐʱºòÓÃWHERE×Ó¾äÎÞ·¨¸øÎÒÃǵIJéѯ¼ÓÈëÌõ¼þ£¬±ÈÈçÔÚÉÏÒ»½ÚÎÒÃÇѧϰµÄGROUP BY(°´×é¹éÀà)×Ӿ䣬Èç¹ûÎÒÃÇÒªÔÚ°´×é¹éÀàºó¼ÓÈëÌõ¼þ£¬ÓÃWHERE¾ÍÐв»Í¨£¬ÒòΪWHEREÖ»¿ÉÒÔÔÚ°´×é¹éÀàÇ°¼ÓÈëÌõ¼þ¡£ºÃÔÚmysqlÌṩHAVING×Ӿ䣬Ëü¿ÉÒÔ°ïÎÒÃǽâ¾öÕâ¸öÎÊÌâ¡£
ÈçºÎÊ¹Ó ......