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

MySQL±¸·ÝºÍ»Ö¸´Êý¾Ý±íµÄ·½·¨

¹Ø¼ü´Ê£ºMySQL  ±¸·Ý  »Ö¸´
¡¡¡¡±¸·ÝÊÇ×î¼òµ¥µÄ±£»¤Êý¾ÝµÄ·½·¨£¬±¾½Ú½«½éÉܶàÖÖ±¸·Ý·½·¨¡£ÎªÁ˵õ½Ò»¸öÒ»Öµı¸·Ý£¬ÔÚÏà¹ØµÄ±íÉÏ×öÒ»¸öLOCK TABLES£¬ÄãÖ»ÐèÒ»¸ö¶ÁËø¶¨£¬µ±ÄãÔÚÊý¾Ý¿âĿ¼ÖÐ×öÎļþµÄÒ»¸ö¿½±´Ê±£¬ÕâÔÊÐíÆäËûÏ̼߳ÌÐø²éѯ¸Ã±í;µ±Äã»Ö¸´Êý¾Ýʱ£¬ÐèÒªÒ»¸öдËø¶¨£¬ÒÔ±ÜÃâ³åÍ»¡£
¡¡¡¡Ê¹ÓÃSQLÓï¾ä±¸·ÝºÍ»Ö¸´
¡¡¡¡Äã¿ÉÒÔʹÓÃSELECT INTO OUTFILEÓï¾ä±¸·ÝÊý¾Ý£¬²¢ÓÃLOAD DATA INFILEÓï¾ä»Ö¸´Êý¾Ý¡£ÕâÖÖ·½·¨Ö»Äܵ¼³öÊý¾ÝµÄÄÚÈÝ£¬²»°üÀ¨±íµÄ½á¹¹£¬Èç¹û±íµÄ½á¹¹ÎļþË𻵣¬Äã±ØÐëÒªÏȻָ´Ô­À´µÄ±íµÄ½á¹¹¡£
¡¡¡¡Óï·¨£º
¡¡¡¡SELECT * INTO {OUTFILE | DUMPFILE} 'file_name' from tbl_name
¡¡¡¡LOAD DATA [LOW_PRIORITY] [LOCAL] INFILE 'file_name.txt' [REPLACE | IGNORE]
¡¡¡¡INTO TABLE tbl_name
¡¡¡¡SELECT ... INTO OUTFILE 'file_name'¸ñʽµÄSELECTÓï¾ä½«Ñ¡ÔñµÄÐÐдÈëÒ»¸öÎļþ¡£ÎļþÔÚ·þÎñÆ÷Ö÷»úÉϱ»´´½¨£¬²¢ÇÒ²»ÄÜÊÇÒѾ­´æÔÚµÄ(²»¹Ü±ðµÄ£¬Õâ¿É×èÖ¹Êý¾Ý¿â±íºÍÎļþÀýÈç“/etc/passwd”±»ÆÆ»µ)¡£SELECT ... INTO OUTFILEÊÇLOAD DATA INFILEÄæ²Ù×÷¡£
¡¡¡¡LOAD DATA INFILEÓï¾ä´ÓÒ»¸öÎı¾ÎļþÖÐÒԺܸߵÄËٶȶÁÈëÒ»¸ö±íÖС£Èç¹ûÖ¸¶¨LOCAL¹Ø¼ü´Ê£¬´Ó¿Í»§Ö÷»ú¶ÁÎļþ¡£Èç¹ûLOCALûָ¶¨£¬Îļþ±ØÐëλÓÚ·þÎñÆ÷ÉÏ¡£(LOCALÔÚMySQL3.22.6»òÒÔºó°æ±¾ÖпÉÓá£)
¡¡¡¡ÎªÁË°²È«Ô­Òò£¬µ±¶ÁȡλÓÚ·þÎñÆ÷ÉϵÄÎı¾Îļþʱ£¬Îļþ±ØÐë´¦ÓÚÊý¾Ý¿âĿ¼»ò¿É±»ËùÓÐÈ˶ÁÈ¡¡£ÁíÍ⣬ΪÁ˶ԷþÎñÆ÷ÉÏÎļþʹÓÃLOAD DATA INFILE£¬ÔÚ·þÎñÆ÷Ö÷»úÉÏÄã±ØÐëÓÐfileµÄȨÏÞ¡£Ê¹ÓÃÕâÖÖSELECT INTO OUTFILEÓï¾ä£¬ÔÚ·þÎñÆ÷Ö÷»úÉÏÄã±ØÐëÓÐFILEȨÏÞ¡£
¡¡¡¡ÎªÁ˱ÜÃâÖظ´¼Ç¼£¬ÔÚ±íÖÐÄãÐèÒªÒ»¸öPRIMARY KEY»òUNIQUEË÷Òý¡£µ±ÔÚΨһË÷ÒýÖµÉÏÒ»¸öмǼÓëÒ»¸öÀϼǼÖظ´Ê±£¬REPLACE¹Ø¼ü´ÊʹµÃÀϼǼÓÃÒ»¸öмǼÌæ´ú¡£Èç¹ûÄãÖ¸¶¨IGNORE£¬Ìø¹ýÓÐΨһË÷ÒýµÄÏÖÓÐÐеÄÖظ´ÐеÄÊäÈë¡£Èç¹ûÄã²»Ö¸¶¨ÈκÎÒ»¸öÑ¡Ïµ±ÕÒµ½Öظ´Ë÷Òýֵʱ£¬³öÏÖÒ»¸ö´íÎ󣬲¢ÇÒÎı¾ÎļþµÄÓàϲ¿·Ö±»ºöÂÔʱ¡£
¡¡¡¡Èç¹ûÄãÖ¸¶¨¹Ø¼ü´ÊLOW_PRIORITY£¬LOAD DATAÓï¾äµÄÖ´Ðб»ÍƳٵ½Ã»ÓÐÆäËû¿Í»§¶ÁÈ¡±íºó¡£
¡¡¡¡Ê¹ÓÃLOCAL½«±ÈÈ÷þÎñÆ÷Ö±½Ó´æÈ¡ÎļþÂýЩ£¬ÒòΪÎļþµÄÄÚÈݱØÐë´Ó¿Í»§Ö÷»ú´«Ë͵½·þÎñÆ÷Ö÷»ú¡£ÔÚÁíÒ»·½Ã棬Äã²»ÐèÒªfileȨÏÞ×°Ôر¾µØÎļþ¡£Èç¹ûÄãʹÓÃLOCAL¹Ø¼ü´Ê´ÓÒ»¸ö±¾µØÎļþ×°ÔØÊý¾Ý£¬·þÎñÆ÷ûÓа취ÔÚ²Ù×÷µÄµ±ÖÐÍ£Ö¹ÎļþµÄ´«Ê䣬Òò´ËȱʡµÄÐÐΪºÃÏñIGNORE±»Ö¸¶¨Ò»Ñù¡£
¡¡¡¡µ±ÔÚ·þÎñÆ


Ïà¹ØÎĵµ£º

JDBC ¼òµ¥µÄMysqlÁ¬½Ó

/*ÑÝʾһ¸öJDBC³ÌÐò£¬´ÓMysqlµÄLMDÊý¾Ý¿âÖжÁ³ö±íadminµÄÒ»¸öÐÅÏ¢*/
import java.sql.*;
public class TestMysqlConnection {
    public static void main(String[] args) {
        Connection conn = null;
        Statement stmt = ......

MySQL grant Óï·¨µÄÏêϸ½âÎö

ÒÔϵÄÎÄÕÂÊÇMySQL grantÓï·¨µÄÏêϸ½âÎö£¬Èç¹ûÄã¶ÔMySQL grantÓï·¨µÄÏà¹ØµÄʵ¼Ê²Ù×÷ÓÐÐËȤµÄ»°£¬Äã¾Í¿ÉÒÔ¶ÔÒÔϵÄÎÄÕµã»÷¹Û¿´ÁË¡£ÎÒÃÇ´ó¼Ò¶¼ÖªµÀMySQLÊý¾Ý¿â¸³ÓèÓû§È¨ÏÞÃüÁîµÄ¼òµ¥¸ñʽ¿É¸ÅÀ¨Îª£º
grant ȨÏÞ on Êý¾Ý¿â¶ÔÏó to Óû§
Ò»¡¢grant ÆÕͨÊý¾ÝÓû§£¬²éѯ¡¢²åÈë¡¢¸üС¢É¾³ý Êý¾Ý¿âÖÐËùÓбíÊý¾ÝµÄȨÀû¡£
grant ......

¸øÄãµÄMySqlÊÜÔ¶³Ì·ÃÎÊȨÏÞ

¸ømysql¿ªÒ»¸ö¿ÉÒÔÔ¶³Ì·ÃÎʵÄÓû§ÃüÁîÈçÏÂ:
GRANT ALL PRIVILEGES ON *.* TO 'myuser'@'%' IDENTIFIED BY 'mypassword' WITH GRANT OPTION;
"*.*" ±íʾÊý¾Ý¿âÖÐËùÓеıí,Ò²¿ÉÒÔ»»³ÉÖ¸¶¨µÄ±íÈçtest.*
"myuser" ±íʾµÄÊÇ·ÃÎʵÄÓû§Ãû;
"%" ±íʾËùÓеÄÖ÷»ú¼´ÈκεÄÖ÷»ú¶¼¿ÉÒÔͨ¹ýÕâ¸öÓû§Ãû·ÃÎÊÎÒµÄÊý¾Ý¿â,Ò²¿ÉÒԸóÉÌض¨µ ......

mysql´æ´¢¹ý³Ì Àý×Ó Óαêcursor Ñ­»·Ç¶Ì× ÊÂÎï

×òÌìÒªmysqlÖÐд´æ´¢¹ý³Ì·¢ÏÖÍøÉÏÓйØÓÚcursorÑ­»·ÇÒÌ×µÄ×ÊÁϺÜÉÙ,ÏÖ·¢³ö±¾ÈËдµÄÀý×Ó,Ï£ÍûÄܶԴó¼ÒÓаïÖú.
¿´ÕÐ:
DELIMITER $$
USE `ad_db`$$
DROP PROCEDURE IF EXISTS `test`$$
CREATE DEFINER=`root`@`%` PROCEDURE `test`()
BEGIN
     /** CPAЧ¹ûÊý */
DECLARE _tmpId1 INT; 
DECLARE ......

Mysql µ¼Èëµ¼³öµÄÎÊÌâ

¹ØÓÚMySqlµÄµ¼Èëµ¼³öÎÊÌâ
    ÔÚÖÕ¶ËÖУ¬½øÈëmysqlµÄ·¾¶ÏµÄbinÖУ¬ÔÚÕâ¸ö·¾¶Ï¿ÉÒÔÖ´ÐÐmysql£¬mysqldumpµÈÃüÁî¡£
    »òÕßÌí¼Ó»·¾³±äÁ¿ ÉèÖû·¾³±äÁ¿path "...(mysqlµÄ°²×°Â·¾¶ÏµÄbinĿ¼)"£¬ÕâÑù¾Í²»±Øÿ´Î¶¼½øÈëÉÏÃæËù˵µÄ·¾¶Ï²Ù×÷¡£
µ¼³öÒ»¸ö¿â£º
    mysqldump ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ