Ô¶³ÌÁ¬½Ó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
Ïà¹ØÎĵµ£º
ÖØ×°Ê±³öÏÖcould not start the service mysql error:0µÄ´íÎóʱ
ÔÚ¿ØÖÆÃæ°åÖÐÔËÐÐÌí¼Óɾ³ý³ÌÐò£¬½«mysqlÐ¶ÔØ;
Ð¶ÔØºó´ò¿ª×¢²á±í£¬²é¿´HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services ϵļüÖµ£¬Èç¹ûÓÐÏà¹Ømysql¼üÖµ(mysql¡¢mysqladmin)Ôòɾµô£¬¼´¿É;
ÖØÆô£¬½«mysqlµÄ°²×°²ÐÓàĿ¼ɾµô (²é¿´·þÎñ£¬´Ëʱ·þÎñÖÐÒÑû ......
ÊÔÑé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 ......
Ò»¡¢Á¬½ÓMYSQL
¸ñʽ£º mysql -hÖ÷»úµØÖ· -uÓû§Ãû -pÓû§ÃÜÂë
1¡¢ÈôÊÇÁ¬½Óµ½±¾»úÉϵÄMYSQL£ºÊ×ÏÈ´ò¿ªDOS´°¿Ú£¬È»ºó½øÈëĿ¼mysql\bin£¬»òÕß½«mysql\bin°²×°Â·¾¶ÉèÖÃÔÚ»·¾³±äÁ¿pathÖУ¬ÔÙ¼üÈëÃüÁîmysql -u root -p£¬»Ø³µºóÌáʾÄãÊäÃÜÂë.×¢ÒâÓû§Ãûǰ¿ÉÒÔÓпոñÒ²¿ÉÒÔûÓпոñ£¬µ«ÊÇÃÜÂëǰ± ......
Query Cache ÔÚÌá¸ßÊý¾Ý¿âÐÔÄÜ·½Ãæ¾ßÓзdz£ÖØÒªµÄ×÷Óá£
ÆäÉ趨Ҳ·Ç³£¼òµ¥£¬½öÐèÒªÔÚÅäÖÃÎļþдÈëÁ½ÐУº query_cache_type ºÍ query_cache _size£¬¶øÇÒ MySQL µÄ query cache ·Ç³£¿ì£¡¶øÇÒÒ»µ©ÃüÖУ¬¾ÍÖ±½Ó·¢Ë͸ø¿Í»§¶Ë£¬½ÚÔ¼´óÁ¿µÄ CPU ʱ¼ä¡£
µ±È»£¬·Ç SELECT Óï¾ä¶Ô»º³åÊÇÓÐÓ°ÏìµÄ£¬ËüÃÇ¿ÉÄÜʹ»º³åÖеÄÊý¾Ý¹ýÆÚ¡£Ò»¸ö ......
Á˽âÁËһЩ×î»ù±¾µÄ²Ù×÷ÃüÁîºó£¬ÎÒÃÇÔÙÀ´Ñ§Ï°ÈçºÎ´´½¨Ò»¸öÊý¾Ý¿âºÍÊý¾Ý¿â±í¡£
1¡¢Ê¹ÓÃSHOWÓï¾äÕÒ³öÔÚ·þÎñÆ÷Éϵ±Ç°´æÔÚʲôÊý¾Ý¿â£º
mysql> SHOW DATABASES;
+----------+
| Database |
+----------+
| mysql |
| test |
+----------+
3 rows in set (0.00 sec) ......