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
¶ÔÓÚÒ»¸öÍøÕ¾
Ïà¹ØÎĵµ£º
1. ÔÚ/etc/my.cnfÖмÓÈëÒ»ÏÂÄÚÈÝ
[mysqld_dev]
socket=/tmp/mysql.sock
port=3307
pid-file=/var/run/mysqld/mysqld_dev.pid
datadir=/var/lib/mysql_dev
log=/var/log/mysqld_dev.log
log-error=/var/log/mysqld_dev.err.log
user=mysql
2. ¸ù¾ÝÒÔÉÏÄÚÈÝ´´½¨Ä¿Â¼ºÍÎļþ
mkdir /var/lib/mysqld_dev
chown mys ......
Æô¶¯mysql: /etc/rc.d/init.d/mysql start
ÐÞ¸ÄÃÜÂë: ¸ñʽ£ºmysqladmin -uÓû§Ãû -p¾ÉÃÜÂë password ÐÂÃÜÂë
ʹÓÃÃÜÂëµÇ¼: mysql -u root -p
ÏÔʾÊý¾Ý¿â: show databases;
Ñ¡ÔñÊý¾Ý¿â: use Êý¾Ý¿âÃû;
ÏÔʾ±í: show tables;
ÏÔʾ±í½á¹¹: descibe ±íÃû;
Ô¶³ÌµÇ¼mysqlÐèÒª¿ªÆôÈ ......
Ò»¡¢½¨±í
DROP TABLE IF EXISTS `user`;
CREATE TABLE `user` (
`ID` int(11) NOT NULL auto_increment,
`NAME` varchar(16) NOT NULL default '',
`REMARK` varchar(16) NOT NULL default '',
PRIMARY KEY (`ID`)
) ENGINE=InnoDB AUTO_INCREMENT=24 DEFAULT CHARSET=utf8;
&nb ......
£©MySql ÖÐÎÄÍø£ºhttp://imysql.cn/onlinedoc
£©MySQL ÖÐÎÄÉçÇø £ºhttp://www.mysql.net.cn/
£©MySql °Ù¶È°Ù¿Æ£ºhttp://baike.baidu.com/view/24816.htm
²Î¿¼×ÊÁÏ£º
MySql°æ±¾¹¹¼Ü¼°Ë÷ÒýÎļþ½éÉÜ
Linux·þÎñÆ÷ÅäÖ÷½°¸MySQL
WinodwsÏÂIIS/Apache PHP MySQLµÄ°²×°ÅäÖÃ
³õѧMySQLÄÄЩÐèÒªÄãÖªµÀ& ......
access denied for user 'root'@'localhost' (using password: YES);
½ñÌìÓÃmysqlµÄʱºò£¬µÇ¼µÄʱºò³öÏÖÁËÕâ¾ä£¬²»ÖªµÀÊÇʲôÒâ˼£¬ÒòΪÎÒµÄmysqlÊÇ×°centosµÄʱºòÒ»Æð×°µÄ£¬ÃÜÂëÎÒ¾ÍÊäÈëÎÒµÄÕÊ»§ÃÜÂ룬½á¹û³öÏÖÁËÉÏÃæÄǾ䣻°Ù¶ÈÁËһϣ¬»¹Õæ²»ÉÙÈ˳öÏÖÁËÕâ¸öÎÊÌâ¡£¡£×îºóÎÒÕÒµ½ÁË·½·¨£»
[root@localhost home]# mysql - ......