mysqlÖÐÎÄÂÒÂë½â¾ö
ÓÉÓÚÄÜÖ±½ÓÔÚMYSQLÊý¾Ý¿âÀïÌí¼ÓÖÐÎÄÊý¾Ý,²¢ÇÒÄÜÕý³£ÏÔʾ,˵Ã÷ÎÒµÄ±í¶¼Ê¹ÓÃÁËÕýÈ·µÄ×Ö·û±àÂë,¾¹ý²é¿´ºó,È·ÈÏÁË,ÎÒÈ«²¿µÄ±íÒÔ¼°×ֶζ¼Ê¹ÓÃÁËUTF-8µÄ±àÂë,µ«ÊÇΪʲô³ÌÐòÌí¼ÓµÄÖÐÎÄÊý¾Ý¾Í²»ÐÐÄØ?
Æäʵ,ÔÒòÔÚÓÚMYSQL·þÎñÆ÷ʹÓõÄĬÈϱàÂë,ÒÔ¼°Êý¾Ý¿âµÄĬÈϱàÂë,ºÜ¶àÈËÒѾºÜСÐĵÄÔÚ½¨Á¢±íʱ¹Ø×¢±íµÄ×Ö·û±àÂë,È´ºöÂÔÁËÊý¾Ý¿âµÄ×Ö·û±àÂë,¶øÔÚûָ¶¨Êý¾Ý¿âµÄ×Ö·û±àÂëʱ,´´½¨µÄÊý¾Ý¿â¾ÍʹÓÃMYSQL·þÎñÆ÷µÄĬÈϱàÂë,µ«ÊÇ,Èç¹ûMYSQL·þÎñÆ÷µÄÅäÖÃÎļþûÓÐÖ¸¶¨±àÂëʱ,ºÜ¿ÉÄܾÍÊÇʹÓõÄlatin1±àÂë.
²é¿´·þÎñÆ÷ºÍÊý¾Ý¿âʹÓúÎÖÖ±àÂëµÄMYSQLÃüÁîΪ:SHOW VARIABLES LIKE 'character_set_%'; ÒÔ¼° SHOW VARIABLES LIKE 'collation_%'; ¿´µ½ÀïÃæʹÓõıàÂëÁË,ÎÒ±¾Ó¦¸ÃʹÓõÄÊÇutf8,ËùÒÔ,²»ÊÇutf8µÄ,ÄǾÍ˵Ã÷ÎÊÌâÔÚÕâÀïÁË.
ÔËÐÐÃüÁî:SHOW VARIABLES LIKE 'character_set_%'; ½á¹ûÈçÏÂ
'character_set_client', 'utf8'
'character_set_connection', 'utf8'
'character_set_database', 'latin1'
'character_set_filesystem', 'binary'
'character_set_results', 'utf8'
'character_set_server', 'latin1'
'character_set_system', 'utf8'
'character_sets_dir', 'D:\soft_work\mysql\share\charsets\'
¹ûÈ»·¢ÏÖÓм¸¸ö²»¶ÔµÄ
ÔËÐÐÃüÁî:SHOW VARIABLES LIKE 'collation_%'; ½á¹ûÈçÏÂ
'collation_connection', 'utf8_general_ci'
'collation_database', 'latin1_general_ci'
'collation_server', 'latin1_general_ci'
ÄÇÔõô°ìÄØ,Ö»Òª°ÑÄǼ¸¸öµÄ±àÂë¸Ä³Éutf8µÄ,ÄÇÓ¦¸Ã¾Í¿ÉÒÔÁË.
1: ÔÚMysqlµÄÅäÖÃÎļþ my.ini (Ò»°ãÔÚc:/windows/ÏÂÃæ) Àï¼ÓÉÏ·þÎñÆ÷µÄĬÈϱàÂëÅäÖÃ: default-character-set=utf8
2: ÐÞ¸ÄÄãµÄÊý¾Ý¿âµÄ×Ö·û±àÂë:½øÈëMysqlÊý¾Ý¿â,ͨ¹ýÃüÁîÐÞ¸ÄÄãµÄÊý¾Ý¿â×Ö·û±àÂë: ALTER DATABASE `databaseName` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci (Ð޸ĺóÐèÒªÖØÆôMysqlÊý¾Ý¿â)
3: Èç¹ûÄãµÄ±íÒÔ¼°±íÀïµÄ×Ö¶ÎʹÓÃÁ˲»ÕýÈ·µÄ×Ö·û±àÂë,ͬÑùÐèÒªÐÞÕý¹ýÀ´:ÃüÁî:
Ð޸ıíµÄ±àÂ룺 ALTER TABLE `tableName` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci
ÐÞ¸Ä×ֶεıàÂ룺 ALTER TABLE `tableName` CHANGE `dd` `dd` VARCHAR( 45 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL
(×öºÃÁËʱ,ÔÙÅÜÒ»ÏÂÉÏÃæÄÇÁ½¸ö²é¿´×Ö·û±àÂëµÄÃüÁî,¿´¿´ÊÇ·ñÈ«²¿¶¼±ä³ÉÁËutf8)
4: Èç¹û»¹Î
Ïà¹ØÎĵµ£º
netbeans6.7ÖÐÏòmysql5ÖвåÈëÖÐÎÄÊý¾ÝʱÏÔʾ”data too long for column“µÄÎÊÌâ¡£
ÎÒµÄmysqlÖÐ×Ö·ûµÄÉèÖÃʱutf-8£¬²¢ÇÒÔÚ¿ØÖÆ̨ÖпÉÒÔ²åÈëÖÐÎÄÊý¾Ý²¢ÏÔʾ£¬µ«ÔÚnetbeansÖвåÈëÊý¾Ýʱȴ×ÜÊÇÏÔʾ”data too long for column“¡£»ù±¾¿ÉÒÔÅжÏÊÇÓÉÓÚnetbeansºÍmysqlÖ®¼äµÄÊý¾Ý½»»»³öÁ ......
´ËÎÄյݲװ·½·¨ÊÊÓÃÓÚWindows XPϵÄApache+PHP+MySQL°²×°¡£ 1. °²×°»·¾³
²Ù×÷ϵͳÊÇ Windows XP ÖÐÎÄ°æ, Apache, PHP, MySQL µÄ×îа汾ÊǽØÖ¹µ½ 2007.09.07£¬·Ö±ðÔÚÆä¹ÙÍøÏÂÔصÄ:
* Apache 2.2.6£ºhttp://apache.mirror.phpchina.com/httpd/binaries/win32/
* PHP 5.2.4 (Windows Binaries PHP 5.2.4 z ......
Æô¶¯Mysql ´íÎó 1067 ½ø³ÌÒâÍâÖÕÖ¹µÄÒ»ÖÖ½â¾ö·½·¨
mysqld-nt --defaults-file=my.ini --standalone --console
²é¿´ÐÅÏ¢ÄÚÈÝ
·¢ÏÖMYSQL INNODB³õʼ»¯´íÎó¡£
´íÎóÈçÏ£º
InnoDB: The first specified data file .\ibdata1 did not exist:
InnoDB: a new database to be created!
100115 10:14:04 InnoDB: Setti ......
Ê×ÏÈÒªÉùÃ÷Ò»µã£¬´ó²¿·ÖÇé¿öÏ£¬ÐÞ¸ÄMySQLÊÇÐèÒªÓÐmysqlÀïµÄrootȨÏ޵ģ¬
ËùÒÔÒ»°ãÓû§ÎÞ·¨¸ü¸ÄÃÜÂ룬³ý·ÇÇëÇó¹ÜÀíÔ±¡£
·½·¨Ò»
ʹÓÃphpmyadmin£¬ÕâÊÇ×î¼òµ¥µÄÁË£¬ÐÞ¸Ämysql¿âµÄuser±í£¬
²»¹ý±ðÍüÁËʹÓÃPASSWORDº¯Êý¡£
·½·¨¶þ
ʹÓÃmysqladmin£¬ÕâÊÇÇ°ÃæÉùÃ÷µÄÒ»¸öÌØÀý¡£
mysqladmin -u root -p password mypas ......
>>mysql:
1¡¢²é¿´ËùÓбíÃû£º
show tables [from db_name];
2¡¢²é¿´×Ö¶ÎÐÅÏ¢
SHOW FULL COLUMNS from db_name.table_name
»ñÈ¡ÒÔÏÂÐÅÏ¢
Field £º×Ö¶ÎÃû
Type£º×Ö¶ÎÀàÐÍ
Collation£º×Ö·û¼¯ £¨mysql 5.0ÒÔÉÏÓУ©
Null £ºÊÇ·ñ¿ÉÒÔΪNULL
Key£ºË÷Òý£¨PRI,unique,index)
Default£ºÈ±Ê¡Öµ
Extra£º¶îÍ⣨ÊÇ·ñ aut ......