³ÌÐò¶ÁmysqlÖÐÎÄÂÒÂëÎÊÌâ½â¾ö·½·¨
Ò»°ãÀ´Ëµ£¬ÂÒÂëµÄ³öÏÖÓÐ2ÖÖÔÒò£¬Ê×ÏÈÊÇÓÉÓÚ±àÂë(charset)ÉèÖôíÎ󣬵¼ÖÂä¯ÀÀÆ÷ÒÔ´íÎóµÄ±àÂëÀ´½âÎö£¬´Ó¶ø³öÏÖÁËÂúÆÁÂÒÆß°ËÔãµÄ“ÌìÊ锣¬Æä´ÎÊÇÎļþ±»ÒÔ´íÎóµÄ±àÂë´ò¿ª£¬È»ºó±£´æ£¬±ÈÈçÒ»¸öÎı¾ÎļþÔÏÈÊÇGB2312±àÂëµÄ£¬È´ÒÔUTF-8±àÂë´ò¿ªÔÙ±£´æ¡£Òª½â¾öÉÏÊöÂÒÂëÎÊÌ⣬Ê×ÏÈÐèÒªÖªµÀ¿ª·¢ÖÐÄÄЩ»·½ÚÉæ¼°µ½Á˱àÂ룺
1¡¢Îļþ±àÂ룺ָµÄÊÇÒ³ÃæÎļþ(.html,.phpµÈ)±¾ÉíÊÇÒÔºÎÖÖ±àÂëÀ´±£´æµÄ¡£¼Çʱ¾ºÍDreamweaverÔÚ´ò¿ªÒ³ÃæÊ±ºò»á×Ô¶¯Ê¶±ðÎļþ±àÂëÒò¶ø²»Ì«»á³öÎÊÌâ¡£¶øZendStudioÈ´²»»á×Ô¶¯Ê¶±ð±àÂ룬ËüÖ»»á¸ù¾ÝÊ×Ñ¡ÏîµÄÅäÖù̶¨ÒÔijÖÖ±àÂë´ò¿ªÎļþ£¬Èç¹û¹¤×÷ʱºòÒ»²»×¢Ò⣬ÓôíÎó±àÂë´ò¿ªÎļþ£¬×öÁËÐÞ¸ÄÖ®ºóÒ»±£´æ£¬ÂÒÂë¾Í³öÏÖÁË¡£
2¡¢Ò³ÃæÉêÃ÷±àÂ룺ÔÚHTML´úÂëHEADÀïÃæ£¬¿ÉÒÔÓÃ<meta http-equiv="Content-Type" content="text/html; charset="XXX" />£¨Õâ¾äÒ»¶¨ÒªÐ´ÔÚ<title>XXX</title>Ç°Ãæ£¬·ñÔò»áµ¼ÖÂÒ³ÃæÒ»Æ¬¿Õ°×£¨½öÏÞIE+PHP£©£©À´¸æËßä¯ÀÀÆ÷ÍøÒ³²ÉÓÃÁËʲô±àÂ룬ĿǰÖÐÎÄÍøÕ¾¿ª·¢ÖÐÖ÷ÒªÓõÄÊÇGB2312ºÍUTF-8Á½ÖÖ±àÂë¡£
3¡¢Êý¾Ý¿âÁ¬½Ó±àÂ룺ָµÄÊǽøÐÐÊý¾Ý¿â²Ù×÷ʱºòÒÔÄÄÖÖ±àÂëÓëÊý¾Ý¿â´«ÊäÊý¾Ý£¬ÕâÀïÐèҪעÒâµÄÊDz»ÒªÓëÊý¾Ý¿â±¾ÉíµÄ±àÂë»ìÏý£¬±ÈÈçMySQLÄÚ²¿Ä¬ÈÏÊÇlatin1±àÂ룬Ҳ¾ÍÊÇ˵MysqlÊÇÒÔlatin1±àÂëÀ´´æ´¢Êý¾Ý£¬ÒÔÆäËû±àÂë´«Ê䏸MysqlµÄÊý¾Ý»á±»×ª»»³Élatin1±àÂë¡££¨Ð°汾µÄmysql 4.1ÒÔÉÏÓ¦¸ÃÒÔutf-8±àÂë´æ´¢£©
ÖªµÀÁËWEB¿ª·¢ÖÐÄÄЩµØ·½Éæ¼°µ½Á˱àÂ룬Ҳ¾ÍÖªµÀÁËÂÒÂë²úÉúµÄÔÒò£ºÉÏÊö3Ïî±àÂëÉèÖò»Ò»Ö£¬ÓÉÓÚ¸÷ÖÖ±àÂë¾ø´ó²¿·ÖÊǼæÈÝASCIIµÄ£¬ËùÒÔÓ¢ÎÄ·ûºÅ²»»á³öÏÖ£¬ÖÐÎľ͵¹Ã¹ÁË¡£ÏÂÃæÊÇһЩ³£¼ûµÄ´íÎóÇé¿öÓë½â¾ö£º
1¡¢Êý¾Ý¿â²ÉÓÃUTF8±àÂ룬¶øÒ³ÃæÉêÃ÷±àÂëÊÇGB2312£¬ÕâÊÇ×î³£¼ûµÄ²úÉúÂÒÂëµÄÔÒò¡£ÕâʱºòÔÚPHP½Å±¾ÀïÃæÖ±½ÓSELECTÊý¾Ý³öÀ´µÄ¾ÍÊÇÂÒÂ룬ÐèÒªÔÚ²éѯǰÏÈʹÓãº
mysql_query("SET NAMES GBK");»òmysql_query("SET NAMES GB2312");À´É趨MYSQLÁ¬½Ó±àÂ룬±£Ö¤Ò³ÃæÉêÃ÷±àÂëÓëÕâÀïÉ趨µÄÁ¬½Ó±àÂëÒ»Ö£¨GBKÊÇGB2312µÄÀ©Õ¹£©¡£Èç¹ûÒ³ÃæÊÇUTF-8±àÂëµÄ»°£¬¿ÉÒÔÓãº
mysql_query("SET NAMES UTF8"); ×¢ÒâÊÇUTF8¶ø²»ÊÇÒ»°ãÓõÄUTF-8¡£¼ÙÈçÒ³ÃæÉêÃ÷µÄ±àÂëÓëÊý¾Ý¿âÄÚ²¿±àÂëÒ»Ö¿ÉÒÔ²»É趨Á¬½Ó±àÂë¡£
×¢£ºÊÂʵÉÏMYSQLµÄÊý¾ÝÊäÈëÊä³ö±ÈÉÏÃæ½²µÄ¸ü¸´ÔÓһЩ£¬MYSQLÅäÖÃÎļþmy.iniÖж¨ÒåÁË2¸öĬÈϱàÂ룬·Ö±ðÊÇ[client]ÀïµÄdefault-character-setºÍ[mysqld]ÀïµÄdefault-character-setÀ´·Ö±ðÉ趨ĬÈÏʱºò¿Í»§¶ËÁ¬½
Ïà¹ØÎĵµ£º
ÈçÈô×ªÔØ£¬Çë×ðÖØ¸öÈËÀͶ¯£¬Îñ±Ø×¢Ã÷Ôʼ³ö´¦£º(http://blog.csdn.net/iihero/archive/2010/05/13/5585039.aspx)
±¾ÎÄΪiihero@CSDNÔ´´¡£
ÔÚǰһƪ¶ÌÎÄÀïÌáµ½ÁËmy.ini/cnfµÄ¼ÓÔØË³Ðò£ºC:\WINDOWS\my.cnf->C:\WINDOWS\my.ini->C:\my.cnf ->C:\my.ini ->$installdir\my.ini¡£(%MYSQL_HOME%\my.ini)-> ......
1Â¥
Ò»¡¢Á¬½ÓMYSQL¡£
¸ñʽ£º mysql -hÖ÷»úµØÖ· -uÓû§Ãû £pÓû§ÃÜÂë
1¡¢Á¬½Óµ½±¾»úÉϵÄMYSQL¡£
Ê×ÏÈ´ò¿ªDOS´°¿Ú£¬È»ºó½øÈëĿ¼mysql\bin£¬ÔÙ¼üÈëÃüÁîmysql -u root -p£¬»Ø³µºóÌáʾÄãÊäÃÜÂë.×¢ÒâÓû§Ãûǰ¿ÉÒÔÓпոñÒ²¿ÉÒÔûÓпոñ£¬µ«ÊÇÃÜÂëǰ±ØÐëÃ»Ó ......
#include "winsock.h"
#include "mysql.h"
void query_example(void)
{
MYSQL *pDbCon = NULL;
char *pszHost = "localhost";
char *pszUser = "guest";
char *pszPsw = "";
char *pszDbName = "mysql_db_name";
int iPort = 3306;
pDbCon = mysql_init((MYSQL*) 0);
if (NULL != pDbCon)
{
......
¾ÍÏóÐí¶àµÄPHP¿ª·¢ÕßÒ»Ñù£¬ÔÚ¸Õ¿ªÊ¼½¨Á¢¶¯Ì¬ÍøÕ¾µÄʱºò£¬ÎÒ¶¼ÊÇʹÓÃÏà¶Ô¼òµ¥
µÄÊý¾Ý½á¹¹¡£PHPÔÚÁ¬½ÓÊý¾Ý¿â·½ÃæµÄȷʵÊÇÊ®·Ö·½±ã£¨ÒëÕß×¢£ºÓÐЩÈËÈÏΪPHPÔÚÁ¬½Ó²»Í¬Êý¾Ý¿âʱûÓÐÒ»¸öͳһµÄ½Ó¿Ú£¬²»Ì«·½±ã£¬ÆäʵÕâ¿ÉÒÔͨ¹ýһЩÀ©
Õ¹¿âÀ´×öµ½ÕâÒ»µã£©£¬ÄãÎÞÐè¿´´óÁ¿µÄÉè¼ÆÎĵµ¾Í¿ÉÒÔ½¨Á¢ºÍʹÓÃÊý¾Ý¿â£¬ÕâÒ²ÊÇPHP»ñµÃ³É¹¦µÄÖ÷ ......
Ê×ÏÈ£ºÈ·¶¨Êý¾Ý¿âµÄ±àÂëΪutf8£¬Õý³£´¢´æÖÐÎÄ£¨ÓÃMySQL-Front²é¿´ÖÐÎÄÊÇ·ñÕý³££©
È»ºó£ºServices²éѯMySQLʱʹÓÃ"SET NAMES 'utf8'"£¬ÇÒͨ¹ý"amfphp/browser"ÔËÐп´¿´ÊÇ·ñÖÐÎÄ£¬Èç¹ûÂÒÂëÔòÐÞ¸Ägateway.phpÎļþ£¬È¥µô $gateway->setCharsetHandler("utf8_decode", "ISO-8859-1", "ISO-8859-1");
×îºó£ºÔËÐÐFlex³ÌÐòÏÔ ......