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

MySQL´æ´¢¹ý³ÌʵÀý

9.3  MySQL´æ´¢¹ý³Ì
MySQL 5.0ÒÔºóµÄ°æ±¾¿ªÊ¼Ö§³Ö´æ´¢¹ý³Ì£¬´æ´¢¹ý³Ì¾ßÓÐÒ»ÖÂÐÔ¡¢¸ßЧÐÔ¡¢°²È«ÐÔºÍÌåϵ½á¹¹µÈÌص㣬±¾½Ú½«Í¨¹ý¾ßÌåµÄʵÀý½²½âPHPÊÇÈçºÎ²Ù×ÝMySQL´æ´¢¹ý³ÌµÄ¡£
ʵÀý261£º´æ´¢¹ý³ÌµÄ´´½¨
ÕâÊÇÒ»¸ö´´½¨´æ´¢¹ý³ÌµÄʵÀý
¼ÏñλÖ㺹âÅÌ\mingrisoft\09\261
ʵÀý˵Ã÷
ΪÁ˱£Ö¤Êý¾ÝµÄÍêÕûÐÔ¡¢Ò»ÖÂÐÔ£¬Ìá¸ßÓ¦ÓõÄÐÔÄÜ£¬³£²ÉÓô洢¹ý³Ì¼¼Êõ¡£MySQL 5.0֮ǰµÄ°æ±¾²¢²»Ö§³Ö´æ´¢¹ý³Ì£¬Ëæ×ÅMySQL¼¼ÊõµÄÈÕÇ÷ÍêÉÆ£¬´æ´¢¹ý³Ì½«ÔÚÒÔºóµÄÏîÄ¿Öеõ½¹ã·ºµÄÓ¦Óᣱ¾ÊµÀý½«½éÉÜÔÚMySQL 5.0ÒÔºóµÄ°æ±¾Öд´½¨´æ´¢¹ý³Ì¡£
¼¼ÊõÒªµã
Ò»¸ö´æ´¢¹ý³Ì°üÀ¨Ãû×Ö¡¢²ÎÊýÁÐ±í£¬ÒÔ¼°¿ÉÒÔ°üÀ¨ºÜ¶àSQLÓï¾äµÄSQLÓï¾ä¼¯¡£ÏÂÃæΪһ¸ö´æ´¢¹ý³ÌµÄ¶¨Òå¹ý³Ì£º
create procedure proc_name (in parameter integer)
begin
declare variable varchar(20);
if parameter=1 then
set variable='MySQL';
else
set variable='PHP';
end if;
insert into tb (name) values (variable);
end;
MySQLÖд洢¹ý³ÌµÄ½¨Á¢ÒԹؼü×Öcreate procedure¿ªÊ¼£¬ºóÃæ½ô¸ú´æ´¢¹ý³ÌµÄÃû³ÆºÍ²ÎÊý¡£MySQLµÄ´æ´¢¹ý³ÌÃû³Æ²»Çø·Ö´óСд£¬ÀýÈçPROCE1()ºÍproce1()´ú±íͬһ¸ö´æ´¢¹ý³ÌÃû¡£´æ´¢¹ý³ÌÃû²»ÄÜÓëMySQLÊý¾Ý¿âÖеÄÄÚ½¨º¯ÊýÖØÃû¡£
´æ´¢¹ý³ÌµÄ²ÎÊýÒ»°ãÓÉ3²¿·Ö×é³É¡£µÚÒ»²¿·Ö¿ÉÒÔÊÇin¡¢out»òinout¡£in±íʾÏò´æ´¢¹ý³ÌÖд«Èë²ÎÊý£»out±íʾÏòÍâ´«³ö²ÎÊý£»inout±íʾ¶¨ÒåµÄ²ÎÊý¿É´«Èë´æ´¢¹ý³Ì£¬²¢¿ÉÒÔ±»´æ´¢¹ý³ÌÐ޸ĺ󴫳ö´æ´¢¹ý³Ì£¬´æ´¢¹ý³ÌĬÈÏΪ´«Èë²ÎÊý£¬ËùÒÔ²ÎÊýin¿ÉÒÔÊ¡ÂÔ¡£µÚ¶þ²¿·ÖΪ²ÎÊýÃû¡£µÚÈý²¿·ÖΪ²ÎÊýµÄÀàÐÍ£¬¸ÃÀàÐÍΪMySQLÊý¾Ý¿âÖÐËùÓпÉÓõÄ×Ö¶ÎÀàÐÍ£¬Èç¹ûÓжà¸ö²ÎÊý£¬²ÎÊýÖ®¼ä¿ÉÒÔÓöººÅ½øÐзָ
MySQL´æ´¢¹ý³ÌµÄÓï¾ä¿éÒÔbegin¿ªÊ¼£¬ÒÔend½áÊø¡£Óï¾äÌåÖпÉÒÔ°üº¬±äÁ¿µÄÉùÃ÷¡¢¿ØÖÆÓï¾ä¡¢SQL²éѯÓï¾äµÈ¡£ÓÉÓÚ´æ´¢¹ý³ÌÄÚ²¿Óï¾äÒªÒԷֺŽáÊø£¬ËùÒÔÔÚ¶¨Òå´æ´¢¹ý³ÌÇ°Ó¦½«Óï¾ä½áÊø±êÖ¾“;”¸ü¸ÄΪÆäËû×Ö·û£¬²¢ÇÒ¸Ã×Ö·ûÔÚ´æ´¢¹ý³ÌÖгöÏֵļ¸ÂÊÒ²Ó¦¸Ã½ÏµÍ£¬¿ÉÒÔÓùؼü×Ödelimiter¸ü¸Ä¡£ÀýÈ磺
mysql>delimiter //
´æ´¢¹ý³Ì´´½¨Ö®ºó£¬¿ÉÓÃÈçÏÂÓï¾ä½øÐÐɾ³ý£¬²ÎÊýproc_nameÖ¸´æ´¢¹ý³ÌÃû¡£
drop procedure proc_name
ʵÏÖ¹ý³Ì
£¨1£©MySQL´æ´¢¹ý³ÌÊÇÔÚ“ÃüÁîÌáʾ·û”Ï´´½¨µÄ£¬ËùÒÔÊ×ÏÈÓ¦¸Ã´ò¿ª“ÃüÁîÌáʾ·û”´°¿Ú¡£
£¨2£©½øÈë“ÃüÁîÌáʾ·û”´°¿Úºó£¬Ê×ÏÈÓ¦¸ÃµÇ¼MySQLÊý¾Ý¿â·þÎñÆ÷£¬ÔÚ“ÃüÁîÌáʾ·û”ÏÂÊäÈëÈçÏÂÃüÁ


Ïà¹ØÎĵµ£º

MySql °´Ê±¼ä¶Î²éѯÊý¾Ý·½·¨


¸ñʽΪ2008-06-16
²éѯ³öµ±ÌìÊý¾Ý£º
SELECT * from `table` WHERE date(ʱ¼ä×Ö¶Î) = curdate();
²éѯ³öµ±ÔÂ×ֶΣº
SELECT *
from `table`
WHERE month( ʱ¼ä×Ö¶Î) = month( now( ) ) ;
ʱ¼ä¸ñʽΪ1219876…… UNIXʱ¼ä£¬Ö»ÒªÓ¦ÓÓfrom_UNIXTIME( )”º¯Êý
ÀýÈç²éѯµ±Ô£º
SELECT ......

MySQLÊý¾Ý¿â±¸·ÝºÍ»¹Ô­µÄ³£ÓÃÃüÁî


±¸·ÝMySQLÊý¾Ý¿âµÄÃüÁî
mysqldump -hhostname -uusername -ppassword databasename > backupfile.sql
±¸·ÝMySQLÊý¾Ý¿âΪ´øɾ³ý±íµÄ¸ñʽ
±¸·ÝMySQLÊý¾Ý¿âΪ´øɾ³ý±íµÄ¸ñʽ£¬Äܹ»Èøñ¸·Ý¸²¸ÇÒÑÓÐÊý¾Ý¿â¶ø²»ÐèÒªÊÖ¶¯É¾³ýÔ­ÓÐÊý¾Ý¿â¡£
mysqldump -–add-drop-table -uusername -ppassword databasename > bac ......

³£Óõ½µÄmysqlÃüÁî±Ê¼Ç

mysqlÉèÖÃÃÜÂëºÍÐÞ¸ÄÃÜÂ룺
/usr/local/mysql/bin/mysqladmin -uroot password 123456 µÚÒ»´ÎÉèÃÜÂë¡£
mysqladmin -uroot -p password mypasswd ÐÞ¸ÄÃÜÂë
ÊäÈëÕâ¸öÃüÁîºó£¬ÐèÒªÊäÈërootµÄÔ­ÃÜÂ룬ȻºórootµÄÃÜÂ뽫¸ÄΪmypasswd¡£
¾ÍÊÇmysql5µ¼³öµÄÓÐdefault-charactµÄÉèÖã¬mysql4²»Ö§³Ö£¬ÐèÒª¼Óskip-opt²ÎÊý£¬È磺
my ......

¸ü¸ÄMySqlÊý¾Ý¿âµÄĬÈϱàÂë¸ñʽ

Ò»¡¢ÉèÖÃÊý¾Ý¿â±àÂë
°²×°mysqlʱ¿ÉÑ¡Ôñ±àÂ룬Èç¹ûÒѾ­°²×°¹ý£¬¿ÉÒÔ¸ü¸ÄÎļþmy.ini(´ËÎļþÔÚmysqlµÄ°²×°Ä¿Â¼ÏÂ)ÖеÄÅäÖÆÒԴﵽĿµÄ£»´ò¿ªÎļþÕÒµ½Á½´¦£º
[client]
port=3306
[mysql]
default-character-set=gb2312
# The default character set that will be used when a new
schema or table is
# created and
n ......

²é¿´¼°ÐÞ¸ÄmysqlÊý¾Ý¿âµÄĬÈϱàÂë2

ʹÓÃmysql ¾­³£»áÓöµ½±àÂëÎÊÌ⣬¶øµ¼Ö³ÌÐò³öÏÖÂÒÂë,mysql ÔÚÒÔϼ¸¸öµØ·½»áÉæ¼°µ½±àÂë¸ñʽ
Êý¾Ý¿â±àÂë
·þÎñÆ÷±àÂë
Á¬½Ó±àÂë
¿Í»§¶Ë±àÂë
ÏÂÃæÊÇÒ»¸öµäÐ͵ÄʾÀý£¬ ÔËÐÐ mysql -u root
²é¿´±àÂë mysql>status
mysql Ver 14.7 Distrib 4.1.14, for Win32 (ia32)
Connection id: 90
Current database: yitian ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ