MySQL ×Ö·û¼¯µ¼ÖÂSQLÁ¬½ÓÖ®ºóÖÐÎÄÂÒÂëµÄÎÊÌ⣡
character-set-server = GB2312
collation-server = latin1_general_ci
MySQL×Ö·û¼¯ GBK¡¢GB2312¡¢UTF8Çø±ð ½â¾ö MYSQLÖÐÎÄÂÒÂëÎÊÌâ ÊÕ²Ø
MySQLÖÐÉæ¼°µÄ¼¸¸ö×Ö·û¼¯
character-set-server/default-character-set£º·þÎñÆ÷×Ö·û¼¯£¬Ä¬ÈÏÇé¿öÏÂËù²ÉÓõġ£
character-set-database£ºÊý¾Ý¿â×Ö·û¼¯¡£
character-set-table£ºÊý¾Ý¿â±í×Ö·û¼¯¡£
ÓÅÏȼ¶ÒÀ´ÎÔö¼Ó¡£ËùÒÔÒ»°ãÇé¿öÏÂÖ»ÐèÒªÉèÖÃcharacter-set-server£¬¶øÔÚ´´½¨Êý¾Ý¿âºÍ±íʱ²»ÌرðÖ¸¶¨×Ö·û¼¯£¬ÕâÑùͳһ²ÉÓÃcharacter-set-server×Ö·û¼¯¡£
character-set-client£º¿Í»§¶ËµÄ×Ö·û¼¯¡£¿Í»§¶ËĬÈÏ×Ö·û¼¯¡£µ±¿Í»§¶ËÏò·þÎñÆ÷·¢ËÍÇëÇóʱ£¬ÇëÇóÒÔ¸Ã×Ö·û¼¯½øÐбàÂë¡£
character-set-results£º½á¹û×Ö·û¼¯¡£·þÎñÆ÷Ïò¿Í»§¶Ë·µ»Ø½á¹û»òÕßÐÅϢʱ£¬½á¹ûÒÔ¸Ã×Ö·û¼¯½øÐбàÂë¡£
ÔÚ¿Í»§¶Ë£¬Èç¹ûûÓж¨Òåcharacter-set-results£¬Ôò²ÉÓÃcharacter-set-client×Ö·û¼¯×÷ΪĬÈϵÄ×Ö·û¼¯¡£ËùÒÔÖ»ÐèÒªÉèÖÃcharacter-set-client×Ö·û¼¯¡£
Òª´¦ÀíÖÐÎÄ£¬Ôò¿ÉÒÔ½«character-set-serverºÍcharacter-set-client¾ùÉèÖÃΪGB2312£¬Èç¹ûҪͬʱ´¦Àí¶à¹úÓïÑÔ£¬ÔòÉèÖÃΪUTF8¡£
¹ØÓÚMySQLµÄÖÐÎÄÎÊÌâ
½â¾öÂÒÂëµÄ·½·¨ÊÇ£¬ÔÚÖ´ÐÐSQLÓï¾ä֮ǰ£¬½«MySQLÒÔÏÂÈý¸öϵͳ²ÎÊýÉèÖÃΪÓë·þÎñÆ÷×Ö·û¼¯character-set-serverÏàͬµÄ×Ö·û¼¯¡£
character_set_client£º¿Í»§¶ËµÄ×Ö·û¼¯¡£
character_set_results£º½á¹û×Ö·û¼¯¡£
character_set_connection£ºÁ¬½Ó×Ö·û¼¯¡£
ÉèÖÃÕâÈý¸öϵͳ²ÎÊýͨ¹ýÏòMySQL·¢ËÍÓï¾ä£ºset names gb2312
¹ØÓÚGBK¡¢GB2312¡¢UTF8
UTF-8£ºUnicode Transformation Format-8bit£¬ÔÊÐíº¬BOM£¬µ«Í¨³£²»º¬BOM¡£ÊÇÓÃÒÔ½â¾ö¹ú¼ÊÉÏ×Ö·ûµÄÒ»ÖÖ¶à×Ö½Ú±àÂ룬Ëü¶ÔÓ¢ÎÄʹÓÃ8루¼´Ò»¸ö×Ö½Ú£©£¬ÖÐÎÄʹÓÃ24Ϊ£¨Èý¸ö×Ö½Ú£©À´±àÂë¡£UTF-8°üº¬È«ÊÀ½çËùÓйú¼ÒÐèÒªÓõ½µÄ×Ö·û£¬Êǹú¼Ê±àÂ룬ͨÓÃÐÔÇ¿¡£UTF-8±àÂëµÄÎÄ×Ö¿ÉÒÔÔÚ¸÷¹úÖ§³ÖUTF8×Ö·û¼¯µÄä¯ÀÀÆ÷ÉÏÏÔʾ¡£È磬Èç¹ûÊÇUTF8±àÂ룬ÔòÔÚÍâ¹úÈ˵ÄÓ¢ÎÄIEÉÏÒ²ÄÜÏÔʾÖÐÎÄ£¬ËûÃÇÎÞÐèÏÂÔØIEµÄÖÐÎÄÓïÑÔÖ§³Ö°ü¡£
GBKÊǹú¼Ò±ê×¼GB2312»ù´¡ÉÏÀ©Èݺó¼æÈÝGB2312µÄ±ê×¼¡£GBKµÄÎÄ×Ö±àÂëÊÇÓÃË«×Ö½ÚÀ´±íʾµÄ£¬¼´²»ÂÛÖС¢Ó¢ÎÄ×Ö·û¾ùʹÓÃË«×Ö½ÚÀ´±íʾ£¬ÎªÁËÇø·ÖÖÐÎÄ£¬½«Æä×î¸ßλ¶¼É趨³É1¡£GBK°üº¬È«²¿ÖÐÎÄ×Ö·û£¬Êǹú¼Ò±àÂ룬ͨÓÃÐÔ±ÈUTF8²î£¬²»¹ýUTF8Õ¼ÓõÄÊý¾Ý¿â±ÈGBD´ó¡£
GBK¡¢GB2312µÈÓëUTF8Ö®¼ä¶¼±ØÐëͨ¹ýUnicode±àÂë²ÅÄÜÏ໥ת»»£º
GBK¡¢GB2312££Unicode££UTF8
UTF8££Unicode££GBK¡¢GB2312
¶ÔÓÚÒ»¸öÍøÕ¾
Ïà¹ØÎĵµ£º
×òÌ죬ÎÒͻȻÏë°ÑÒ»¸öÊý¾Ý¿âÀïµÄÿ¸ö±í£¬ÒÔ¼°Ã¿¸ö±íµÄ·Ç¿Õ×ܼͼÊý´æÔÚÁíÒ»¸ö±íÀïÃæ¡£
Ê×ÏÈ£¬´´½¨ÁËÒ»¸ö´æ·ÅÊý¾ÝµÄ±í£º
create table tables
(
name varchar(50),
number int
);
insert into tables select table_name from information_schema.tables where table_shema = 'test';
µ«ÊDz»ÖªµÀÓÐûÓз½·¨£¬½«·Ç¿ÕµÄ ......
Èç¹ûÄãÊǸöÈü³µÊÖ²¢ÇÒ°´Ò»Ï°´Å¥¾ÍÄܹ»Á¢¼´¸ü»»ÒýÇæ¶ø²»ÐèÒª°Ñ³µ¿ªµ½³µ¿âÀïÈ¥»»£¬ÄÇ»áÊÇÔõô¸Ð¾õÄØ£¿MySQLÊý¾Ý¿âΪ¿ª·¢ÈËÔ±Ëù×öµÄ¾ÍºÃÏñÊÇ°´°´Å¥»»ÒýÇ棻ËüÈÃÄãÑ¡ÔñÊý¾Ý¿âÒýÇ棬²¢¸øÄãÒ»Ìõ¼òµ¥µÄ;¾¶À´Çл»Ëü¡£
MySQL µÄ×Ô´øÒýÇæ¿Ï¶¨Êǹ»ÓÃÁË£¬µ«ÊÇÔÚÓÐЩÇé¿öÏ£¬ÆäËûµÄÒýÇæ¿ÉÄÜÒª±ÈÊÖÍ·ËùÓøüÊʺÏÍê³ÉÈÎÎñ¡£Èç¹ûÔ¸Ò ......
Ò»¡¢ÉèÖÃÊý¾Ý¿â±àÂë
°²×°mysqlʱ¿ÉÑ¡Ôñ±àÂ룬Èç¹ûÒѾ°²×°¹ý£¬¿ÉÒÔ¸ü¸ÄÎļþmy.ini(´ËÎļþÔÚmysqlµÄ°²×°Ä¿Â¼ÏÂ)ÖеÄÅäÖÆÒԴﵽĿµÄ£»´ò¿ªÎļþÕÒµ½Á½´¦£º
[client]
port=3306
[mysql]
default-character-set=gb2312
# The default character set that will be used when a new
schema or table is
# created and
n ......
»ù±¾µÄMySQLÓï¾äºÜ¼òµ¥£¬ÕâÀïÖ÷Ҫ̸̸һЩÈÝÒ×ÒÅÍüµÄ¡£
1.ÈçºÎÉèÖÃ×ֶεÝÔö
create table tb_User(Id int auto_increment
not null primary key,UserName varchar(50),Password varchar(20));
2.²é¿´±í½á¹¹
desc tb_User;
3.ÈçºÎÐ޸ıí½á
ÖØÃüÃû±í£ºalter table tb_User rename
tb_UserInfo;
Ìí¼ÓÒ»ÁУºalter ta ......
access denied for user 'root'@'localhost' (using password: YES);
½ñÌìÓÃmysqlµÄʱºò£¬µÇ¼µÄʱºò³öÏÖÁËÕâ¾ä£¬²»ÖªµÀÊÇʲôÒâ˼£¬ÒòΪÎÒµÄmysqlÊÇ×°centosµÄʱºòÒ»Æð×°µÄ£¬ÃÜÂëÎÒ¾ÍÊäÈëÎÒµÄÕÊ»§ÃÜÂ룬½á¹û³öÏÖÁËÉÏÃæÄǾ䣻°Ù¶ÈÁËһϣ¬»¹Õæ²»ÉÙÈ˳öÏÖÁËÕâ¸öÎÊÌâ¡£¡£×îºóÎÒÕÒµ½ÁË·½·¨£»
[root@localhost home]# mysql - ......