MYSQLË÷ÒýµÄʹÓÃ
ÔÚÊý¾Ý¿â±íÖУ¬¶Ô×ֶν¨Á¢Ë÷Òý¿ÉÒÔ´ó´óÌá¸ß²éѯËٶȡ£¼ÙÈçÎÒÃÇ´´½¨ÁËÒ»¸ö
mytable
񡜧
CREATE TABLE mytable(
ID INT NOT NULL,
username VARCHAR(16) NOT NULL
);
ÎÒÃÇËæ»úÏòÀïÃæ²åÈëÁË
10000
Ìõ¼Ç¼£¬ÆäÖÐÓÐÒ»Ìõ£º
5555, admin
¡£
ÔÚ²éÕÒ
username="admin"
µÄ¼Ç¼
SELECT * from mytable WHERE username='admin';
ʱ£¬Èç¹ûÔÚ
username
ÉÏÒѾ½¨Á¢ÁËË÷Òý£¬
MySQL
ÎÞÐëÈκÎɨÃ裬¼´×¼È·¿ÉÕÒµ½¸Ã¼Ç¼¡£Ïà·´£¬
MySQL
»áɨÃèËùÓмǼ£¬¼´Òª²éѯ
10000
Ìõ¼Ç¼¡£
Ë÷Òý·Öµ¥ÁÐË÷ÒýºÍ×éºÏË÷Òý¡£µ¥ÁÐË÷Òý£¬¼´Ò»¸öË÷ÒýÖ»°üº¬µ¥¸öÁУ¬Ò»¸ö±í¿ÉÒÔÓжà¸öµ¥ÁÐË÷Òý£¬µ«Õâ²»ÊÇ×éºÏË÷Òý¡£×éºÏË÷Òý£¬¼´Ò»¸öË÷°üº¬¶à¸öÁС£
Ë÷ÒýµÄÀàÐÍ°üÀ¨£º
£¨1
£©ÆÕͨË÷Òý
ÕâÊÇ×î»ù±¾µÄË÷Òý£¬ËüûÓÐÈκÎÏÞÖÆ¡£ËüÓÐÒÔϼ¸ÖÖ´´½¨·½Ê½£º
¡ñ
´´½¨Ë÷Òý
CREATE INDEX indexName ON mytable(username(length));
Èç¹ûÊÇ
CHAR
£¬
VARCHAR
ÀàÐÍ£¬
length
¿ÉÒÔСÓÚ×Ö¶Îʵ¼Ê³¤¶È£»Èç¹ûÊÇ
BLOB
ºÍ
TEXT
ÀàÐÍ£¬±ØÐëÖ¸¶¨
length
£¬ÏÂͬ¡£
¡ñ
Ð޸ıí½á¹¹
ALTER mytable ADD INDEX [indexName] ON (username(length))
¡ñ
´´½¨±íµÄʱºòÖ±½ÓÖ¸¶¨
CREATE TABLE mytable(
ID INT NOT NULL,
username VARCHAR(16) NOT NULL,
INDEX [indexName] (username(length))
);
ɾ³ýË÷ÒýµÄÓï·¨£º
DROP INDEX [indexName]
ON mytable;
£¨2
£©Î¨Ò»Ë÷Òý
ËüÓëÇ°ÃæµÄÆÕͨË÷ÒýÀàËÆ£¬²»Í¬µÄ¾ÍÊÇ£ºË÷ÒýÁеÄÖµ±ØÐëΨһ£¬µ«ÔÊÐíÓпÕÖµ¡£Èç¹ûÊÇ×éºÏË÷Òý£¬ÔòÁÐÖµµÄ×éºÏ±ØÐëΨһ¡£ËüÓÐÒÔϼ¸ÖÖ´´½¨·½Ê½£º
¡ñ
´´½¨Ë÷Òý
CREATE UNIQUE INDEX indexName ON mytable(username(length))
¡ñ
Ð޸ıí½á¹¹
ALTER mytable ADD UNIQUE [indexName] ON (username(length))
¡ñ
´´½¨±íµÄʱºòÖ±½ÓÖ¸¶¨
CREATE TABLE mytable(
ID INT NOT NULL,
username VARCHAR(16) NOT NULL,
UNIQUE [indexName] (username(length))
);
£¨3
£©Ö÷¼üË÷Òý
ËüÊÇÒ»ÖÖÌØÊâµÄΨһË÷Òý£¬²»ÔÊÐíÓпÕÖµ¡£Ò»°ãÊÇÔÚ½¨±íµÄʱºòͬʱ´´½¨Ö÷¼üË÷Òý£º
CREATE TABLE mytable(
ID INT NOT NULL,
username VARCHAR(16) NOT NULL,
PRIMARY KEY(ID)
);
µ±È»Ò²¿ÉÒÔÓÃ
ALTER
ÃüÁî¡£¼Çס£ºÒ»¸ö±íÖ»ÄÜÓÐÒ»¸
Ïà¹ØÎĵµ£º
1¡¢µÇ½MySQL:
mysql -u root -p
2¡¢²é¿´Óû§ÐÅÏ¢
select user,host,password from mysql.user;
select user,host from mysql.user;
3¡¢ÉèÖÃÃÜÂë
set password for root@localhost=password('
ÔÚÕâÀïÌîÈërootÃÜÂë
');
4¡¢ÐÞ¸ÄÃÜÂë
·½·¨1£ºmysqladmin -u root -p password newpassword
·½·¨2£º ££mysql -u root ......
ת×Ô:http://blog.chinaunix.net/u2/85344/showart_2042280.html
LiunxÏÂÐÞ¸ÄMySQL×Ö·û¼¯£º
1.²éÕÒMySQLµÄcnfÎļþµÄλÖÃ
find / -iname '*.cnf' -print
/usr/share/mysql/my-innodb-heavy-4G.cnf
/usr/share/mysql/my-large.cnf
/usr/share/mysql/my-small.cnf
/usr/share/mysql/my-medium.cnf
/usr/share/mysql ......
Êý¾Ý¿âĿ¼ÊÇMySQLÊý¾Ý¿â·þÎñÆ÷´æ·ÅÊý¾ÝÎļþµÄµØ·½£¬²»½ö°üÀ¨ÓйرíµÄÎļþ£¬»¹°üÀ¨Êý¾ÝÎļþºÍMySQLµÄ·þÎñÆ÷Ñ¡ÏîÎļþ¡£²»Í¬µÄ·Ö·¢£¬Êý¾Ý¿âĿ¼µÄȱʡλÖÃÊDz»Í¬µÄ¡£
Êý¾ÝĿ¼µÄλÖÃ
ȱʡµÄÊý¾Ý¿âλÖÃ
ȱʡÊý¾Ý¿âµÄλÖñàÒëÔÚ·þÎñÆ÷ÖС£
¡ôÈç¹ûÄúÊÇÔÚÒ»¸öÔ´³ÌÐò·Ö·¢°üÖа²×° MySQL£¬µäÐ͵ÄȱʡλÖÿÉÄÜÊÇ /usr/local/var ......
Ò»¡¢ÏÂÔØMySQL
¹Ù·½ÍøÕ¾£ºwww.mysql.org
¶þ¡¢°²×°
1.½«´ËѹËõ°ü½âѹËõµ½Öƶ¨Îļþ¼ÐÏ£¬ÒÔ"C:/mysql"ΪÀý
2.½«my-midium.ini¸´ÖÆÒ»·Ý£¬²¢ÖØÃüÃûΪmy.ini
3.½«C:/mysql/bin/libmysql.dll¸´ÖƵ½ÏµÍ³Ä¿Â¼Ï£¬ÀýÈ縴ÖƵ½"C:/windows"ÏÂ
4.ÔÚÃüÁîÐÐģʽÏ£¬ÔËÐÐC:/mysql/bin/mysqld£¬¼´¿É¿ªÆôMySQL·þÎñ ......