mysqlÐÔÄܵļì²éºÍµ÷ÓÅ·½·¨
ÎÒÒ»Ö±ÊÇʹÓÃmysqlÕâ¸öÊý¾Ý¿âÈí¼þ£¬Ëü¹¤×÷±È½ÏÎȶ¨£¬Ð§ÂÊÒ²ºÜ¸ß¡£ÔÚÓöµ½ÑÏÖØÐÔÄÜÎÊÌâʱ£¬Ò»°ã¶¼ÓÐÕâô¼¸ÖÖ¿ÉÄÜ£º
1¡¢Ë÷ÒýûÓн¨ºÃ£»
2¡¢sqlд·¨¹ýÓÚ¸´ÔÓ£»
3¡¢ÅäÖôíÎó£»
4¡¢»úÆ÷ʵÔÚ¸ººÉ²»ÁË£»
1¡¢Ë÷ÒýûÓн¨ºÃ
Èç¹û¿´µ½mysqlÏûºÄµÄcpuºÜ´ó£¬¿ÉÒÔÓÃmysqlµÄclient¹¤¾ßÀ´¼ì²é¡£
ÔÚlinuxÏÂÖ´ÐÐ
/usr/local/mysql/bin/mysql -hlocalhost -uroot -p
ÊäÈëÃÜÂ룬Èç¹ûûÓÐÃÜÂ룬Ôò²»ÓÃ-p²ÎÊý¾Í¿ÉÒÔ½øµ½¿Í»§¶Ë½çÃæÖС£
¿´¿´µ±Ç°µÄÔËÐÐÇé¿ö
show full processlist
¿ÉÒÔ¶àÔËÐм¸´Î
Õâ¸öÃüÁî¿ÉÒÔ¿´µ½µ±Ç°ÕýÔÚÖ´ÐеÄsqlÓï¾ä£¬Ëü»á¸æÖªÖ´ÐеÄsql¡¢Êý¾Ý¿âÃû¡¢Ö´ÐеÄ״̬¡¢À´×ԵĿͻ§¶Ëip¡¢ËùʹÓõÄÕʺš¢ÔËÐÐʱ¼äµÈÐÅÏ¢
ÔÚÎÒµÄcacheºó¶Ë£¬ÕâÀïÃæ´ó²¿·Öʱ¼äÊÇ¿´²»µ½ÏÔʾÈκÎsqlÓï¾äµÄ£¬ÎÒÈÏΪÕâÑù²ÅËã±È½ÏÕý³£¡£Èç¹û¿´µ½ÓкܶàsqlÓï¾ä£¬ÄÇôÕą̂mysql¾ÍÒ»¶¨»áÓÐÐÔÄÜÎÊÌâ
Èç¹û³öÏÖÁËÐÔÄÜÎÊÌ⣬Ôò¿ÉÒÔ½øÐзÖÎö£º
1¡¢ÊDz»ÊÇÓÐsqlÓï¾ä¿¨×¡ÁË£¿
ÕâÊdzöÏֱȽ϶àµÄÇé¿ö£¬Èç¹ûÊý¾Ý¿âÊDzÉÓÃmyisam£¬ÄÇôÓпÉÄÜÓÐÒ»¸öдÈëµÄÏ̻߳á°ÑÊý¾Ý±í¸øËø¶¨ÁË£¬Èç¹ûÕâÌõÓï¾ä²»½áÊø£¬ÔòÆäËüÓï¾äÒ²ÎÞ·¨ÔËÐС£
²é¿´processlistÀïµÄtimeÕâÒ»Ï¿´¿´ÓÐûÓÐÖ´ÐÐʱ¼äºÜ³¤µÄÓï¾ä£¬ÒªÁôÒâÕâЩÓï¾ä¡£
2¡¢´óÁ¿ÏàͬµÄsqlÓï¾äÕýÔÚÖ´ÐÐ
Èç¹û³öÏÖÕâÖÖÇé¿ö£¬ÔòÓпÉÄÜÊǸÃsqlÓï¾äÖ´ÐеÄЧÂʵÍÏ£¬Í¬ÑùÒªÁôÒâÕâЩÓï¾ä¡£
È»ºó°ÑÄãËù»³ÒɵÄÓï¾äͳͳ¼¯ºÏһϣ¬ÓÃdesc£¨explain£©À´¼ì²éÕâЩÓï¾ä¡£
Ê×ÏÈ¿´¿´Ò»¸öÕý³£µÄdescÊä³ö£º
mysql> desc select * from imgs where imgid=1651768337;
+----+-------------+-------+-------+---------------+---------+---------+-------+------+-------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+-------+-------+---------------+---------+---------+-------+------+-------+
| 1 | SIMPLE | imgs | const | PRIMARY | PRIMARY | 8 | const | 1 | |
+----+-------------+-------+-------+---------------+---------+---------+-------+------+-------+
1 row in set (0.00 sec)
×¢Òâkey¡¢rowsºÍExtraÕâÈýÏÕ
Ïà¹ØÎĵµ£º
Íü¼ÇMySQL ROOTÃÜÂëÊÇÔÚMySQLʹÓÃÖкܳ£¼ûµÄÎÊÌ⣬¿ÉÊÇÓкܶàÅóÓѲ¢²»»áÖØÖÃROOTÃÜÂ룬Äǽпడ£¬ÎÒÓÐÉîÓид¥£¬ÌØд´ËÎÄÕÂÓë´ó¼Ò½»Á÷£º
1¡¢±à¼MySQL(ºÍPHP´îÅäÖ®×î¼Ñ×éºÏ)ÅäÖÃÎļþ£º
windows»·¾³ÖУº%MySQL_installdir%\my.ini
//Ò»°ãÔÚMySQL°²×°Ä¿Â¼ÏÂÓÐmy.ini¼´MySQLµÄÅäÖÃÎļþ¡£
linux»·¾³ÖУº/etc/my.cnf ......
°²×°ºó
/etc/init.d/mysql start (stop) ΪÆô¶¯ºÍÍ£Ö¹·þÎñÆ÷
/etc/mysql/ Ö÷ÒªÅäÖÃÎļþËùÔÚλÖà my.cnf
/var/lib/mysql/ ·ÅÖõÄÊÇÊý¾Ý¿â±íÎļþ¼Ð£¬ÕâÀïµÄmysqlÏ൱ÓÚwindowsÏÂmysqlµÄdateÎļþ¼Ð
Æô¶¯mysqlºó£¬ÒÔrootµÇ¼mysql
isher@isher-ubuntu:~$ mysql -u root
>show variables like 'character%'; #Ö´ÐбàÂëÏ ......
mysqlÊý¾ÝÂÒÂëÎÊÌâÔÒò¼°½â¾ö£¨×ܽáƪ£©
µÚÒ»½â¾ö·½·¨£º
ÂÒÂëÎÊÌâ¼òµ¥Ëµ¾ÍÊÇÊý¾Ý¿âдÈë¶ÁÈ¡£¬ÍøÒ³Îļþ£¬ÍøÒ³ÏÔʾʱ¼¸¸ö»·½ÚµÄ±àÂë²»Ò»ÖÂÔì³ÉµÄ¡£
ÂÒÂëÎÊÌâ
дÈëʱ£ºÒ³ÃæÌáȡдÈëÊý¾Ý±àÂëºÍдÈëÊý¾Ý¿âʱ±àÂë²»Ò»ÖÂ
¶Áȡʱ£º¶ÁÈ¡ºóËùÓñàÂëÓëÊý¾Ý¿âдÈëʱ²»Ò»ÖÂ
......
mysql ´ó¶ÔÏó´æÈ¡:
¡¡¡¡ÀàÐÍÒ»°ãÓ¦¸ÃÓÃmediumblod,
¡¡¡¡blobÖ»ÄÜ´æ2µÄ16´Î·½¸öbyte,
¡¡¡¡mediumblodÊÇ24´Î·½,
¡¡¡¡Ò»°ãÀ´Ëµ¹»ÓÃÁË.longblobÊÇ32´Î·½ÓÐЩ´ó.
¡¡¡¡MYSQLĬÈÏÅäÖÃÖ»ÄÜ´æ1M´óСµÄÎļþ,ÒªÐÞ¸ÄÅäÖÃ,WIN°æ±¾µÄÔÚmysql.iniÎļþÖÐ
¡¡¡¡ÐÞ¸Ämax_allowed_packet,net_buffer_lengthµÈ¼¸¸ö²ÎÊý,»òÖ±½ÓSET GLOBAL va ......
¹ØÓÚÐÞ¸ÄmysqlµÄrootÃÜÂëµÄ½â´ð£¨×ܽáƪ£©
ÕûÀíÁËÒÔÏÂËÄÖÖÔÚMySQLÖÐÐÞ¸ÄrootÃÜÂëµÄ·½·¨,Ö÷ÒªÊÇÓÐʱºò×Ô¼ºÓöµ½ÁËÕâ¸öÎÊÌâ²»ÖªµÀÔõô¸ãÁË£¬µ±È»Èç¹ûÄܸø¹ã´óµÄPHPer½â¾öÎÊÌâÒ²ÊÇÎÒµÄÈÙÐÒ°¡£¬ºÇºÇ¡£
·½·¨1£º ÓÃSET PASSWORDÃüÁî
¡¡¡¡mysql -u root
¡¡¡¡mysql> SET PASSWORD FOR 'root'@'localhost' = PASSWORD('n ......