.net·ÃÎÊMysqlһЩϸ½ÚÎÊÌâ
²ÉÓõÄÊÇMySql¹Ù·½ÌṩµÄ.NET connector£¬´ËÇý¶¯Ö»ÐèÒªÏÂÔؼ´¿ÉʹÓãºhttp://dev.mysql.com/downloads/connector/net/1.0.html
ÔÚʹÓÃÖлýÀÛÁ˼¸µã¾Ñ飺
1)ʹÓÃParameter²ÎÊýÐÎʽÌá½»Commandʱ±ØÐëÒª°Ñ"@"ºÅ»»³É"?"ºÅ£¬ÕâÒ»µãÈÃÎÒÀ§»óÁËÒ»Ì죬ֻÊDz»Ã÷°×MySQLΪºÎÒª¸ãÌØÊâÄØ£¬ÏóMS¡¢ODP.NET for Oracle¡¢OleDbµÈ·½Ê½£¬¶¼ÊÇÓÃ"@"ºÅµÄ¡£
Àý×ÓÈçÏ£º
string connstr=Setting.Instance().GetConnectionString("MySql");
MySqlConnection conn =new MySqlConnection(connstr);
conn.Open();
string query = "insert into myfirst(Id,Name) values(?Id,?Name)";
MySqlCommand cmd = new MySqlCommand(query, conn);
MySqlParameter para1=new MySqlParameter("?Id",DbType.Int32); //ÕâÀïҪעÒâ±ØÐëÒªÓÃ?ºÅ
MySqlParameter para2=new MySqlParameter("?Name",DbType.String);//ÕâÀïҪעÒâ±ØÐëÒªÓÃ?ºÅ
para1.Value=5;
para2.Value="ddd";
cmd.Parameters.Add(para1);
cmd.Parameters.Add(para2);
cmd.ExecuteNonQuery();
2)ÔÚMySQLÖÐÒ²Óб£Áô×Ö£¬ÎªÁËÌṩ¼æÈÝ£¬ÎÒ±ØÐëÒªÕÒµ½¶¨½ç·û£¬ºÃ²»ÈÝÒ×ÔÚMySqlµÄÂÛ̳ÀïÕÒµ½ÁË£¬Ê¹ÓõĶ¨½ç·ûÊÇ`£¬Õâ¸ö·ûºÅ²»Êǵ¥ÒýºÅ£¬¶øÊǼüÅÌÉÏÊý×Ö1Ç°ÃæµÄÄǸö“µã”£¬ÕæÊǺ¦ËÀÎÒ°¡¡£
3£©MySQLÖеÄTOP¹¦Äܵ¹ÊǷdz£¼òµ¥£¬Ö»ÐèÒªÓï¾äºóÃæʹÓÓlimit n”¾ÍÐÐÁË£¬Õâ±ÈORACLEµÄÄÇRownum·½±ã¶àÁË¡£
ʹÓÃMySql µÄ.NET Connector·ÃÎÊMySQL×ÜÌåÀ´Ëµ»¹Ëã²»´íµÄ£¬´ó²¿·ÖÊǼæÈÝ.NETÖеÄIConnection¡¢ICommandµÄ¡£
PS£ºÓиö²»Ã÷°×¾ÍÊÇÔÚ.NET ConnectorÖÐÌṩһ¸öMySqlDateTimeÀ࣬²»ÖªµÀÕâ¸öÀà¾ßÌåÓÐʲôÓã¬ÔõôÓã¬ÔÚ¹úÄÚûÓÐÕÒµ½Ïà¹ØµÄ×ÊÁÏ¡£MySqlDateTime¸úSystem.Date»¹²»¼æÈÝ£¬ÔÚMySQLÂÛ̳ÉÏÏà¹ØÌû×ÓN¶à¡£
Èç¹û²ÉÓÃStringÀàÐ͵ÄParameter´«µÝ¸øMySqlµÄDateTime×ֶλᱨ£ºUnable to Convert MySql Date/Time value to System.DateTime µÄ´íÎó¡£
MysqlÓï¾ä¼Ó ×Ö¶ÎÓС¾¡¿ ¾Í»á±¨´íÎ󣡣¡£¡£¡£¡£¡£¡
Ò²ÊǸտªÊ¼Ñ§mysql,ÏÂÃæÊÇÎÒ´ÓÍøÉÏÕÒµ½µÄ,ÎÒ¸Õ²ÅÊÔ¹ýÁË,¿ÉÒÔ, ÎÒµÄÊÇmysql5.0µÄ
mysql ·þÎñÆ÷Ö§³Ö # µ½¸ÃÐнáÊø¡¢-- µ½¸ÃÐнáÊø ÒÔ¼° /* ÐÐÖмä»ò¶à¸öÐÐ */ µÄ×¢ÊÍ·½¸ñ£º
mysql> SELECT 1+1; # Õâ¸ö×¢ÊÍÖ±
Ïà¹ØÎĵµ£º
TIMESTAMPÁÐÀàÐÍÌṩһÖÖÀàÐÍ£¬Äã¿ÉÒÔʹÓÃËü×Ô¶¯µØÓõ±Ç°µÄÈÕÆÚºÍʱ¼ä±ê¼ÇINSERT»òUPDATEµÄ²Ù×÷¡£Èç¹ûÄãÓжà¸öTIMESTAMPÁУ¬Ö»ÓеÚÒ»¸ö×Ô¶¯¸üС£
×Ô¶¯¸üеÚÒ»¸öTIMESTAMPÁÐÔÚÏÂÁÐÈκÎÌõ¼þÏ·¢Éú£º
ÁÐûÓÐÃ÷È·µØÔÚÒ»¸öINSERT»òLOAD DATA INFILEÓï¾äÖÐÖ¸¶¨¡£
ÁÐûÓÐÃ÷È·µØÔÚÒ ......
Ò»¡¢MYSQL´æ´¢ÒýÇæ´óÈ«£º
·MyISAM£ºÄ¬ÈϵÄMySQL²å¼þʽ´æ´¢ÒýÇ棬ËüÊÇÔÚWeb¡¢Êý¾Ý²Ö´¢ºÍÆäËûÓ¦Óû·¾³ÏÂ×ʹÓõĴ洢ÒýÇæÖ®Ò»¡£×¢Ò⣬ͨ¹ý¸ü¸ÄSTORAGE_ENGINEÅäÖñäÁ¿£¬Äܹ»·½±ãµØ¸ü¸ÄMySQL·þÎñÆ÷µÄĬÈÏ´æ´¢ÒýÇæ¡£
·InnoDB£ºÓÃÓÚÊÂÎñ´¦ÀíÓ¦ÓóÌÐò£¬¾ßÓÐÖÚ¶àÌØÐÔ£¬°üÀ¨ACIDÊÂÎñÖ§³Ö¡£
·BDB£º¿ÉÌæ´úI ......
»·¾³£ºÁ½Ì¨·þÎñÆ÷IP:192.168.30.57\192.168.30.58
1¡¢ÏÂÔØmysql-5.0.86-linux-i686-glibc23.tar.gz µ½http://dev.mysql.com/downloads/mysql/5.0.html#linuxÏÂÔØ
2¡¢½âѹ tar -zxvf
mysql-5.0.86-linux-i686-glibc23.tar.gz
3¡¢´´½¨Á´½Ó ln -s
mysql-5.0.86-linux-i686-g ......
12.8. Castº¯ÊýºÍ²Ù×÷·û
BINARY
BINARY²Ù×÷·û½«ºóÃæµÄ×Ö·û´®Å׸øÒ»¸ö¶þ½øÖÆ×Ö·û´®¡£ÕâÊÇÒ»ÖÖ¼òµ¥µÄ·½Ê½À´´ÙʹÖð×Ö½Ú¶ø²»ÊÇÖð×Ö·ûµÄ½øÐÐÁбȽϡ£ÕâʹµÃ±È½ÏÇø·Ö´óСд£¬¼´Ê¹¸ÃÁв»±»¶¨ÒåΪ BINARY»ò BLOB¡£BINARYÒ²»á²úÉú½áβ¿Õ°×£¬´Ó¶ø¸ü¼ÓÏÔ ......