Ò׽ؽØÍ¼Èí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

mysqlÀàÐÍת»»

MYSQL Castº¯Êý ÀàÐÍת»»
BINARY
BINARY²Ù×÷·û½«ºóÃæµÄ×Ö·û´®Å׸øÒ»¸ö¶þ½øÖÆ×Ö·û´®¡£ÕâÊÇÒ»ÖÖ¼òµ¥µÄ·½Ê½À´´ÙʹÖð×Ö½Ú¶ø²»ÊÇÖð×Ö·ûµÄ½øÐÐÁбȽϡ£ÕâʹµÃ±È½ÏÇø·Ö´óСд£¬¼´Ê¹¸ÃÁв»±»¶¨ÒåΪ BINARY»ò BLOB¡£BINARYÒ²»á²úÉú½áβ¿Õ°×£¬´Ó¶ø¸ü¼ÓÏÔÑÛ¡£
mysql> SELECT 'a' = 'A';
-> 1
mysql> SELECT BINARY 'a' = 'A';
-> 0
mysql> SELECT 'a' = 'a ';
-> 1
mysql> SELECT BINARY 'a' = 'a ';
-> 0
BINARYÓ°ÏìÕû¸ö±È½Ï£»Ëü¿ÉÒÔÔÚÈκβÙ×÷Êýǰ±»¸ø¶¨£¬¶ø²úÉúÏàͬµÄ½á¹û¡£
BINARY str ÊÇCAST(str AS BINARY)µÄËõÂÔÐÎʽ¡£
×¢Ò⣬ÔÚһЩÓï¾³ÖУ¬¼ÙÈçÄ㽫һ¸ö±àÈëË÷ÒýµÄÁÐÅɸøBINARY, MySQL ½«²»ÄÜÓÐЧʹÓÃÕâ¸öË÷Òý¡£
¼ÙÈçÄãÏëÒª½«Ò»¸ö BLOBÖµ»òÆäËü¶þ½øÖÆ×Ö·û´®½øÐÐÇø·Ö´óСдµÄ±È½Ï£¬Äã¿ÉÀûÓöþ½øÖÆ×Ö·û´®Ã»ÓÐ×Ö·û¼¯ÕâÒ»ÊÂʵʵÏÖÕâ¸öÄ¿µÄ£¬ÕâÑù¾Í²»»áÓÐÎÄÊé¼ÐµÄ¸ÅÄΪִÐÐÒ»¸öÇø·Ö´óСдµÄ±È½Ï£¬¿ÉʹÓà CONVERT()º¯Êý½«Ò»¸ö×Ö·û´®Öµ×ª»¯ÎªÒ»¸ö²»Çø·Ö´óСдµÄ×Ö·û¼¯¡£Æä½á¹ûΪһ¸ö·Ç¶þ½øÖÆ×Ö·û´®£¬Òò´Ë LIKE ²Ù×÷Ò²²»»áÇø·Ö´óСд£º
SELECT 'A' LIKE CONVERT(blob_col USING latin1) from tbl_name;
ÈôҪʹÓÃÒ»¸ö²»Í¬µÄ×Ö·û¼¯, Ìæ»»ÆäÔÚÉÏÊöÓï¾äÖеÄlatin1Ãû¡£
CONVERT()Ò»°ã¿ÉÓÃÓڱȽϳöÏÖÔÚ²»Í¬×Ö·û¼¯ÖеÄ×Ö·û´®¡£
CAST(expr AS type), CONVERT(expr,type) , CONVERT(expr USING transcoding_name)
CAST() ºÍCONVERT() º¯Êý¿ÉÓÃÀ´»ñȡһ¸öÀàÐ͵ÄÖµ£¬²¢²úÉúÁíÒ»¸öÀàÐ͵ÄÖµ¡£
Õâ¸öÀàÐÍ ¿ÉÒÔÊÇÒÔÏÂÖµÆäÖÐµÄ Ò»¸ö£º
BINARY[(N)]
CHAR[(N)]
DATE
DATETIME
DECIMAL
SIGNED [INTEGER]
TIME
UNSIGNED [INTEGER]
BINARY ²úÉúÒ»¸ö¶þ½øÖÆ×Ö·û´®¡£¹ØÓÚËüÔõÑùÓ°Ïì±È½Ï½á¹ûµÄ˵Ã÷¼û±¾ÕÂÖÐ BINARY²Ù×÷·ûÏî¡£
¼ÙÈç¸ø¶¨ÁËËæÒⳤ¶ÈN£¬Ôò BINARY[N] ʹ castʹÓøòÎÊýµÄ²»¶àÓÚ N ¸ö×Ö½Ú¡£Í¬ÑùµÄ£¬ CHAR[N]»áʹ cast ʹÓøòÎÊýµÄ²»¶àÓÚN ¸ö×Ö·û¡£
CAST() and CONVERT(... USING ...) ÊDZê×¼ SQLÓï·¨¡£CONVERT()µÄ·ÇUSING ¸ñʽÊÇofis ODBCÓï·¨¡£
´øÓÐUSINGµÄCONVERT() ±»ÓÃÀ´ÔÚ²»Í¬µÄ×Ö·û¼¯Ö®¼äת»¯Êý¾Ý¡£ÔÚ MySQLÖÐ, ×Ô¶¯ÒëÂëÃûºÍÏàÓ¦µÄ×Ö·û¼¯Ãû³ÆÏàͬ¡£ÀýÈç¡£ Õâ¸öÓï¾ä½«·þÎñÆ÷µÄĬÈÏ×Ö·û¼¯ÖеÄ×Ö·û´® 'abc'ת»¯Îªutf8×Ö·û¼¯ÖÐÏàÓ¦µÄ×Ö·û´®£º
SELECT CONVERT('abc' USING utf8);
µ±ÄãÏëÒªÔÚÒ»¸öCREATE ... SELECT Óï¾äÖд´½¨Ò»¸öÌØÊâÀàÐ͵ÄÁУ¬Ôòcastº¯Êý»áºÜÓÐÓãº
CREATE T


Ïà¹ØÎĵµ£º

MySQLµÄ³£ÓòÙ×÷½éÉÜ

   ×¢Ò⣺MySQLÖÐÿ¸öÃüÁîºó¶¼ÒªÒԷֺţ»½áβ¡£
£¨1£©ÏÔʾÊý¾Ý¿â
mysql> show databases;
+----------+
| Database |
+----------+
| mysql |
| test |
+----------+
2 rows in set (0.04 sec)
   Mysql¸Õ°²×°ÍêÓÐÁ½¸öÊý¾Ý¿â£ºmysqlºÍtest¡£ÆäÖУ¬mysql¿â·Ç³£ÖØÒª£¬ËüÀïÃæÓÐMyS ......

MySQLÖÐÔö¼ÓÐÂÓû§²¢¶ÔÆä¸³ÓèÏàӦȨÏ޵İ취

£¨1£©¸ñʽ£ºgrant select on Êý¾Ý¿â.* to Óû§Ãû@µÇ¼Ö÷»ú identified by "ÃÜÂë"
 
£¨2£©Àý1¡¢Ôö¼ÓÒ»¸öÓû§user_1ÃÜÂëΪ123£¬ÈÃËû¿ÉÒÔÔÚÈκÎÖ÷»úÉϵǼ£¬²¢¶ÔËùÓÐÊý¾Ý¿âÓвéѯ¡¢²åÈë¡¢Ð޸ġ¢É¾³ýµÄȨÏÞ¡£Ê×ÏÈÓÃÒÔrootÓû§Á¬ÈëMySQL£¬È»ºó¼üÈëÒÔÏÂÃüÁ
mysql> grant select,insert,update,delete on *.* to use ......

MySQL AdministratorÎÞ·¨Á¬½Ó·þÎñÆ÷µÄ½â¾ö·½·¨

   ĬÈÏÇé¿öÏÂLinuxÄÚµÄmysqlÊý¾Ý¿âmysql.user±íÄÚµÄÓû§È¨ÏÞÖ»ÊǶÔlocalhost¼´±¾»ú²ÅÄܵǽ¡£ËùÒÔÐèÒª¸ü¸ÄȨÏÞ£¬·ñÔòÎÞ·¨Ê¹ÓÃMysql AdministratorÁ¬½Ó·þÎñÆ÷£¬»á·¢ÉúÈçÏÂËùʾµÄ´íÎó£º
      MySQL Administrator 1.1.9ÅäÖÃ,Á¬½ÓmysqlÊý¾Ý¿â
      Could no ......

Æô¶¯ºÍ¹Ø±ÕMySQLµÄ·½·¨

£¨1£©Æô¶¯
     MySQL°²×°Íê³ÉºóÆô¶¯ÎļþmysqlÔÚ/etc/init.dĿ¼Ï£¬ÔÚÐèÒªÆô¶¯MySQL·þÎñʱÔËÐÐÏÂÃæÃüÁî¼´¿É¡£ [root@test1 init.d]# /etc/init.d/mysql start
£¨2£©Í£Ö¹
      /usr/bin/mysqladmin -u root -p shutdown
£¨3£©ÉèÖÃMySQL×Ô¶¯Æô¶¯
1£©²ì¿´mysqlÊÇ·ñÔÚ×Ô¶ ......

ÀûÓÃmysqlµÄ×¢ÉäµãµÃµ½¸ü¶àmysqlµÄÐÅÏ¢

µ±×¢Éämysql¿âµÄÊäÈëµãµÄʱºò,ÎÒÃÇ¿ÉÒÔͨ¹ýversion()/user()/database()/password()µÈÄÚÖú¯ÊýÀ´µÃµ½mysqlµÄÏà¹ØÐÅÏ¢,ÆäʵÎÒÃÇÔÚ×¢ÉäµÄʱºò¿ÉÒÔÀûÓÃmysqlÄÚÖõıäÁ¿À´µÃµ½¸ü¶àµÄmysqlÐÅÏ¢
ÆäÖÐversion()¿ÉÒÔд³É@@versionÀ´°Ñversionµ±×ö±äÁ¿À´¶ÁÈ¡,ÕâÑùÒ»Ñù¿ÉÒԵõ½,ÆäËûµÄÄÚÖÃÊDz»¿ÉÒÔд³É±äÁ¿µÄÐÎʽ.
´ó¼Ò¶¼Ó¦¸ÃÓùýÀû ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ