Ô¶³ÌÁ¬½ÓmysqlËÙ¶ÈÂýµÄ½â¾ö·½·¨
Ô¶³ÌÁ¬½ÓmysqlËÙ¶ÈÂýµÄ½â¾ö·½·¨
http://www.xishuiw.com
¡¡¡¡PHP Ô¶³ÌÁ¬½ÓMYSQLËÙ¶ÈÂý,ÓÐʱԶ³ÌÁ¬½Óµ½MYSQLÓÃʱ4-20Ãë²»µÈ,±¾µØÁ¬½ÓMYSQLÕý³£,³öÏÖÕâÖÖÎÊÌâµÄÖ÷ÒªÔÒòÊÇ,ĬÈÏ°²×°µÄMYSQL¿ªÆôÁËDNSµÄ·´Ïò½âÎö,ÔÚMY.INI(WINDOWSϵͳÏÂ)»òMY.CNF(UNIX»òLINUXϵͳÏÂ)ÎļþµÄ[mysqld]ϼÓÈëskip- name-resolveÕâÒ»¾ä¡£Á¬½ÓmysqlËÙ¶ÈÂýµÄ½â¾ö·½·¨.
¡¡¡¡2̨·þÎñÆ÷£¬Ò»Ì¨ÅÜiis+php£¬Ò»Ì¨ÅÜmysql£¬ºÍÒÔÍùÒ»ÑùÅäÖúû·¾³£¬²âÊÔÒ³ÃæÒ»ÇÐOK
¡¡¡¡ÅÜÓ¦ÓõÄʱºò·¢ÏÖphp·ÃÎÊmysqlËٶȺÜÂý£¬ÕâÖÖÇé¿öÔÚÒÔÇ°´Óδ·¢ÏÖ¹ý£¬ËäÈ»2̨·þÎñÆ÷²¢·ÇÔÚͬһÍø¶ÎÖУ¬µ«ÊÇpingÊýÖµ»ù±¾É϶¼ÔÚ1,2ms Ö®¼ä£¬tcpÁ¬½ÓÓ¦¸Ã²»ÊÇÎÊÌâ¹Ø½¡£¬googleÒÔºóÕÒµ½´ð°¸£¬ÔÚmy.iniÎļþµÄ[mysqld]²¿·Ö¼ÓÈë:skip-name-resolve£¬±£´æÎļþ£¬ÖØÆômysql£¬Ò»ÇÐOKÀ²£¬ËÙ¶ÈÏó·ÉÒ»ÑùÁË
¡¡¡¡Ð°汾µÄmysqlÅäÖÃÆðÀ´²»ÏóÒÔÇ°µÄÄǸöɵ¹Ï»¯ÁË£¬Õâ¸öÎÊÌâÕÛÌÚÁËÎÒÒ»ÉÏÎçµÄʱ¼ä£¬ÍíÉÏ»ØÀ´×ÜËãÊǽâ¾öÁË£¬ºÙºÙ£¬ÓÖѧµ½Ò»Ð©¶«Î÷¡£
¡¡¡¡Windows 2003ϵÄMySQL 5·þÎñÆ÷£¬±¾»úÁ¬½Óµ½MySQL·þÎñ·Ç³£¿ì£¬¾ÖÓòÍøÄÚÓÐÁ½Ì¨Linux»úÆ÷£¬ÓÐһ̨Á¬½ÓºÜ¿ì£¬ÁíÍâһ̨ÊäÈëÃÜÂëºóÒªµÈºÃ¼¸ÃëÖÓ²ÅÄÜÁ¬ÉÏ¡£
½â¾ö°ì·¨£º
ÔÚMySQL·þÎñÆ÷µÄÅäÖÃÖÐÔö¼ÓÒ»¸öÈçÏÂÅäÖúóËٶȷɿ졣
[mysqld]
skip-name-resolve
¸½Â¼£º( How MySQL uses DNS )
When a new thread connects to mysqld, mysqld will spawn a new thread to handle the request. This thread will first check if the hostname is in the hostname cache. If not the thread will call gethostbyaddr_r() and gethostbyname_r() to resolve the hostname.
If the operating system doesn't support the above thread-safe calls, the thread will lock a mutex and call gethostbyaddr() and gethostbyname() instead. Note that in this case no other thread can resolve other hostnames that is not in the hostname cache until the first thread is ready.
You can disable DNS host lookup by starting mysqld with --skip-name-resolve. In this case you can however only use IP names in the MySQL privilege tables.
If you have a very slow DNS and many hosts, you can get more performance by either disabling DNS lookop with --skip-name-resolve or by increasing the HOST_CACHE_SIZE define (default: 128) and recompile mysqld.
You can disable the h
Ïà¹ØÎĵµ£º
LIMIT×Ó¾ä¿ÉÒÔ±»ÓÃÀ´ÏÞÖÆSELECTÓï¾ä·µ»ØµÄÐÐÊý¡£LIMITÈ¡1¸ö»ò2¸öÊý×Ö²ÎÊý£¬Èç¹û¸ø¶¨2¸ö²ÎÊý£¬µÚÒ»¸öÖ¸¶¨Òª·µ»ØµÄµÚÒ»ÐеÄÆ«ÒÆÁ¿£¬µÚ¶þ¸öÖ¸¶¨·µ»ØÐеÄ×î´óÊýÄ¿¡£³õʼÐеÄÆ«ÒÆÁ¿ÊÇ0(²»ÊÇ1)¡£ mysql> select * from table LIMIT 5,10; # Retrieve rows 6-15 Èç¹û¸ø¶¨Ò»¸ö²ÎÊý£¬ËüÖ¸³ö·µ»ØÐеÄ×î´óÊýÄ¿¡£ mysql> select * ......
ÊÔÑé1
ÊÂÎñ1£º
#!/usr/bin/python
import time
import MySQLdb;
conn = MySQLdb.connect(host="localhost",port=3306,user="root",passwd="asdf",db="test",unix_socket="/data/mysql_3306/mysql.sock")
cursor = conn.cursor()
cursor.execute("select * from test")
while str!="1":
str = r ......
1.mysqlÊÇÒ»¸ö·Ç³£·½±ãµÄ¹ÜÀímysql·þÎñÆ÷µÄ¿Í»§¶ËÈí¼þ¡£ ´´½¨Ò»¸ömysql·þÎñÆ÷µÄÁ¬½ÓµÄʱºòÓ¦¸Ã×¢ÒâÌîдÐÅÏ¢µÄʱºòÏÈÔÚ×¢²áÀ¸ÌîдµÇ½Óû§ÃûºÍÃÜÂ룬ÔÙÔÚÁ¬½ÓÀ¸Ìîд·þÎñÆ÷Ãû£¬¶Ë¿ÚºÅ¡£
2.ʹÓÃmysql-frontµÄʱºò£¬½¨Á¢Ò»¸öµÇ½ÊôÐÔÒÔºó£¬ÔÙÔÚÃüÁîÐвÙ×÷mysqlÊý¾Ý¿â£¬mysql-frontµÄÊý¾ÝÐèÒªÊÖ¶¯Í¬²½²Å¿ÉÒÔ¿´µ½Ê¹ÓÃÃüÁîÐжÔÊý¾ ......
²âÊÔ»·¾³£ºUbuntu 9.10 + MySQL 5.1.37-1ubuntu5
Ubuntu ÔÚÆô¶¯¹ÜÀí init.d
ÀïÃæ¹ØÓÚ MySQL µÄÃüÁîÓУº
/etc/init.d/mysql start|stop|restart|reload|force-reload|status
ÀýÈçÖØÆôMySQL·þÎñ£ºsudo /etc/init.d/mysql restart
......
±¾À´ÊÇmssql+hibernate+native SQL Ó¦ÓõĺܺÍг
µ«Êǵ½ÁË°Ñmssql»»³Émysql£¬¾Í³öÁË´í(ͬÑùµÄÊý¾Ý½á¹¹ºÍÊý¾Ý)¡£
²éѯ·½·¨ÊÇ£º
String sql =
"select id XXX_ID from t_tab";
List<Map> list = session.createSQLQuery(sql)
.setResultTransformer(Transformers.ALIAS_TO_ENTITY_MAP)
.list();
´í ......