MySQL³£ÓÃÃüÁî×ܽá
MySQL³£ÓÃÃüÁî×ܽá
===MySQL»ù´¡====
mysqlÏÂÔØ: http://www.mysql.com/
mysqld ³£¹æMySQL·þÎñÆ÷
mysqld-opt ÓÅ»¯mysql·þÎñÆ÷,ÌṩһЩ¹¦ÄÜ¿ÉÒÔÍÚ¾ò¸üºÃµÄ¹¦ÄÜ
mysqld-max ÓëmysqldÒ»Ñù,µ«¿ÉÒÔÖ§³Ö¸üÐÂ,¸ü¾ßʵÑéÐÔÖʵŦÄÜ(¸ü²»Îȶ¨)
++°²×°mysql
²Î¼û×Ô´øµÄINSTALL-SOURCEÎļþ
$ ./configure –prefix=/app/mysql-5.0.51a –with-charset=utf8 –with-extra-charsets=gbk,gb2312,utf8
++Æô¶¯/¹Ø±Õmysql
$ path/mysqld_safe -user=mysql &
$ /mysqladmin -p shutdown
++ÐÞ¸Äroot¿ÚÁî
$ mysqladmin -u root -p password ‘ÐÂÃÜÂë’
++²é¿´·þÎñÆ÷״̬
$ path/mysqladmin version -p
++Á¬½ÓÔ¶¶Ëmysql·þÎñÆ÷
$ path/mysql -u Óû§Ãû -p #Á¬½Ó±¾»ú
$ path/mysql -h Ô¶³ÌÖ÷»úIP -u Óû§Ãû -p#Á¬½ÓÔ¶³ÌMYSQL·þÎñÆ÷
++´´½¨/ɾ³ý Êý¾Ý¿â»ò±í
$ mysqladmin -u root -p create xxx
mysql> create database Êý¾Ý¿âÃû;
mysql> create TABLE items (
id INT(5) NOT NULL AUTO_INCREMENT PRIMARY KEY ,
symbol CHAR(4) NOT NULL,
username CHAR(8),
INDEX sym (symbol),INDEX …..
UNIQUE(username)
) type=innodb;
mysql> drop database [if exists] Êý¾Ý¿âÃû
mysql> create table ±íÃû;
mysql> drop table ±íÃû;
++²é¿´Êý¾Ý¿âºÍ²é¿´Êý¾Ý¿âϵıí
mysql> show databases;
mysql> show tables;
mysql> show table status;
mysql> desc ±íÃû; #²é¿´¾ßÌå±í½á¹¹ÐÅÏ¢
mysql> SHOW CREATE DATABASE db_name #ÏÔʾ´´½¨db_name¿âµÄÓï¾ä
mysql> SHOW CREATE TABLE tbl_name #ÏÔʾ´´½¨tbl_name±íµÄÓï¾ä
++´´½¨Óû§
mysql> grant select,insert,update,delete,alter on mydb.* to test2@localhost identified by “abc”;
mysql> grant all privileges on *.* to test1@”%” identified by “abc”;
mysql> flush privileges;
++Óû§¹ÜÀí
mysql> update user set password=password (’11111′) where user=’test1′; #ÐÞ¸Ätest1ÃÜÂëΪ111111
mysql> DELETE from user WHERE User=”testuser” and Host=”localhost”; #ɾ³ýÓû§ÕʺÅ
mysql> SHOW GRANTS FOR user1; #ÏÔʾ´´½¨user1Óû§µÄgrantÓï¾ä
++mysqlÊý¾Ý¿âµÄ±¸·ÝºÍ»Ö¸´
$ mysqldump -uuser -ppasswo
Ïà¹ØÎĵµ£º
´ËÎÄÕÂÖ÷ÒªÃèÊöµÄÊÇMySQLÊý¾ÝÀàÐÍÓ뽨¿â²ßÂÔµÄÏêϸ½âÎö£¬ÎÒÃÇ´ó¼Ò¶¼ÖªµÀÎÞÂÛÊÇÔÚ²»ÊշѵÄÊý¾Ý¿â¿Õ¼ä»òÕßÊÇ´óÐ͵ĵç×ÓÉÌÎñÍøÕ¾£¬ÆäºÏÀíµÄÉè¼Æ±í½á¹¹¡¢³ä·ÖÀûÓÿռäÊÇÊ®·Ö±ØÒªµÄ¡£
¡¡¡¡Õâ¾ÍÒªÇóÎÒÃǶÔÊý¾Ý¿âϵͳµÄ³£ÓÃMySQLÊý¾ÝÀàÐÍÓгä·ÖµÄÈÏʶ¡£ÏÂÃæÎҾͽ«ÎÒµÄÒ»µãÐĵÃд³öÀ´¸ú´ó¼Ò·ÖÏí¡£
¡¡¡¡Ò»¡¢MySQLÊý¾ÝÀàÐÍÖ®Êý×ÖÀàÐ ......
Ê×ÏȽ¨Ò»¸ö¹¤³Ì£¬×¼±¸ºÃlog4jµÄjar°üºÍMysqLµÄÇý¶¯°ü¡£
ÅäÖÃlog4j.propertiesÎļþ£º
#´Ë¾äΪ¶¨ÒåÃûΪstdoutµÄÊä³ö¶ËÊÇÄÄÖÖÀàÐÍ£¬¿ÉÒÔÊÇ
#org.apache.log4j.ConsoleAppender£¨¿ØÖÆ̨£©£¬
#org.apache.log4j.FileAppender£¨Îļþ£©£¬
#org.apache.log4j.DailyRollingFileAppender£¨Ã¿Ìì²úÉúÒ»¸öÈÕÖ¾ÎÄ ......
°æȨÉùÃ÷
£º×ªÔØʱÇëÒÔ³¬Á´½ÓÐÎʽ±êÃ÷ÎÄÕÂÔʼ³ö´¦ºÍ×÷ÕßÐÅÏ¢¼°±¾ÉùÃ÷
http://bbayou.blogbus.com/logs/37045617.html
²âÊÔÊý¾Ý2.5G£¬¹²ÓÐÊý¾Ý9427567Ìõ¡£ÓõÄmysqlµÄlarge·þÎñÆ÷µÄÅäÖá£
load
Ò»´ÎÐèÒª´ó¸Å10·ÖÖÓ×óÓÒ¡£
½¨µÄ±íÓõÄÊÇMYISAM£¬µ÷ÕûÁ˼¸¸ösessionµÄ²ÎÊýÖµ
SET
SESSION
BULK_INSERT_BUFFER_S ......
MySQLÖеÄÁ÷³Ìº¯Êý
º¯Êý
¹¦ÄÜ
IF(value,t ,f)
Èç¹ûvalueΪÕ棬·µ»Øt£¬·ñÔò·µ»Øf
IFNULL(value1,value2)
Èç¹ûvalue1²»Îª¿Õ·µ»Øvalue1,·ñÔò·µ»Øvalue2
CASE WHEN [value1] THEN [result1] … ELSE [default] END
Èç¹ûvalue1ΪÕæ ·µ»Øresult2 ·ñÔò·µ»Ødefault
CASE [expr] WHEN [value1] THEN [result1] &helli ......