UbuntuÏÂmysqlÐÞ¸Ä×Ö·û¼¯
Ê×ÏÈÍ£Ö¹MySQL·þÎñ£ºsudo /etc/init.d/mysql stop
È»ºó±à¼MySQLÅäÖÃÎļþ£ºsudo gedit /etc/mysql/my.cnf
ÔÚmy.cnfÎļþÖеÄ[client]¶ÎÏÂÃæ¼ÓÈë
default-character-set=utf8
[mysqld_safe]
default-character-set=utf8
[mysqld]
default-character-set=utf8
[mysql]
default-character-set=utf8
ÖØÐÂÆô¶¯MySQL·þÎñ£¬
sudo /etc/init.d/mysql start
½øÈëMySQLµÄÃüÁîÌáʾ·ûÏÂÊäÈëÈçÏÂÖ¸Á
mysql>show variables like '%char%';
Èç¹û³öÏÖµÄÁбí¸÷ÏîÄÚÈݺÍÒÔÏÂÏàͬ±íÃ÷ÅäÖóɹ¦ÁË£¬
---------------------£ -----££--------------
| Variable_name | Value
----------------------- -££------------------
| character_set_client | utf8
| character_set_connection | utf8
| character_set_database | utf8
| character_set_filesystem | binary
| character_set_results | utf8
| character_set_server | utf8
| character_set_system | utf8
| character_sets_dir | /usr/share/mysql/charsets/
È»ºó°ÑÔÀ´µÄÊý¾Ý¿âɾÁË£¬ÔÙн¨£¨ÎÒ¾ÍÊÇÕâÑù×öµÄ£¬²»ÕâÑù×ö»¹ÊÇ»á³ö´í£©
ÏÖÔÚÖÐÎÄÊý¾ÝÄܹ»²åÈëÁË
Ïà¹ØÎĵµ£º
ÕâÀïÊÇÒ»¸öʹÓÃÈÕÆÚº¯ÊýµÄÀý×Ó¡£ÏÂÃæµÄ²éѯѡÔñÁËËùÓмǼ£¬Æädate_colµÄÖµÊÇÔÚ×îºó30ÌìÒÔÄÚ£º
mysql> SELECT something from table
WHERE TO_DAYS(NOW()) - TO_DAYS(date_col) <= 30;
DAYOFWEEK(date)
·µ»ØÈÕÆÚdateµÄÐÇÆÚË÷Òý(1=ÐÇÆÚÌ죬2=ÐÇÆÚÒ», ……7=ÐÇÆÚÁù)¡£ÕâЩË÷ÒýÖµ¶ÔÓ¦ÓÚODBC±ê ......
Ò»¡¢
¿ØÖÆÁ÷³Ìº¯Êý
a)
CASE WHEN THEN
º¯Êý
Óï·¨£º
CASE value WHEN [compare-value]
THEN result [WHEN [compare-value] THEN result ……] [ELSE result ] END CASE WHEN
[condition] THEN result [WHEN[condition] THEN result …… ......
solarisÏÂmysql°²×°Íê±ÏºóÖ´ÐÐÈçϲÙ×÷£¬¿ÉÒÔÐÞ¸ÄÊý¾Ý¿â×Ö·û¼¯£¬ÉèÖÃMySQLÔÚSolarisÉϱíÃû²»Çø·Ö´óСд
1.¿½±´ÎļþÈçÏ£º
cp /usr/sfw/share/mysql/my-medium.cnf /etc/my.cnf
°ÑÎļþÖ»¶ÁÊôÐÔÈ¥µô
chmod +w my.cnf
2 ÉèÖÃmysqlµÄ×Ö·û¼¯£ºÔÚ/etc/my.cnfÖеÄmysqld¶ÎºÍclient¶Î¼ÓÈë´úÂ룺
[client]
de ......
--default-character-set=utf8 ÓëÐÞ¸ÄsqlÎļþ¼ÓÈ룺SET NAMES 'utf8';
µ¼Èë½Å±¾Ê±£¬SET NAMES 'xxx' £¬xxxÓ¦¸ÃºÍsql½Å±¾ÎļþµÄʵ¼Ê±àÂëÒ»Ö£¬Èç¹ûÄãÉèÖõÄʱutf-8 £¬ÄÇôÇëÈ·ÈÏÄãµÄsql½Å±¾Îļþʱutf-8±£´æµÄ:
iconv -f UTF-8 xxx.sql
Èç¹ûÏÔʾÕý³££¬ÄÇôÕâÒ»²½¾ÍOKÁË
ÁíÍâ×¢ÒâÄãµÄ½Å±¾ÀÓÐûÓиø¿â±íÉèÖ ......