Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

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 ÃüÁî¡£¼Çס£ºÒ»¸ö±íÖ»ÄÜÓÐÒ»¸öÖ÷¼ü¡£
£¨4£©×éºÏË÷Òý
ΪÁËÐÎÏóµØ¶Ô±Èµ¥ÁÐË÷ÒýºÍ×éºÏË÷Òý£¬Îª±íÌí¼Ó¶à¸ö×ֶΣº
CREATE TABLE mytable(
ID IN


Ïà¹ØÎĵµ£º

perlÒ»¸ö¼òµ¥mysql²Ù×÷µÄС³ÌÐò

#!/usr/bin/perl
use Mysql;
print "Content-type:
text/html \n\n";
# MySQL
ÅäÖñäÁ¿
$host = "localhost";
$database
= "testdb";
$tablename = "testtable";
$user = "username";
$pw =
"password";
# PERL MYSQL CONNECT()
$connect = ......

MySQL³£ÓõÄһЩÓÐЧÃüÁîÂÞÁÐ

¼ò¼òµ¥µ¥µÄÂÞÁÐһЩÈÕ³£³£ÓõÄMySQLÃüÁî¡£
show variables;
²é¿´Êý¾Ý¿âÅäÖõÄһЩÅäÖÃÏî
show status;
²é¿´µ±Ç°Æô¶¯µÄMySQL״̬
select @@autocommit;
²é¿´MySQLµ±Ç°Ö´ÐÐSQLµÄÌá½»ÀàÐÍ£¨ÊÇ·ñ×Ô¶¯Ìá½»£©
\s
µ±Ç°Á¬½ÓÊý¾Ý¿âÃû£¬Óû§Ãû£¬MySQL°æ±¾£¬×Ö·û¼¯µÈµÈ¡£
show create table table_name \G
²é¿´´´½¨±íµÄSQLÓï ......

MYSQLÍü¼ÇROOTÃÜÂëºó£¿

 
 MYSQLÍü¼ÇROOTÃÜÂëºó£¿
 
ÐÞ¸ÄMySQLµÄµÇ¼ÉèÖãº
1.È¡ÏûȨÏÞ¹ÜÀí
±à¼­ /mysql5.1/my.ini
ÔÚ[mysqld]µÄ¶ÎÖмÓÉÏÒ»¾ä£ºskip-grant-tables
ÀýÈ磺
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
skip-name-resolve
skip-grant-tables
Ä¿µÄÊÇΪÁË£º
Ìø¹ýMySQLµÄ·ÃÎ ......

MySQLÒýÇæ¼ò½é

MySQLÊÇÎÒÃDZȽϳ£ÓõÄÒ»ÖÖÊý¾Ý
¿âÈí¼þ¡£ËüÓÐ×ÅÖî¶àµÄÓŵ㣬È翪ԴµÄ£¬Ãâ·ÑµÄµÈµÈ¡£ÆäʵËü»¹ÓÐÒ»¸öºÜºÃµÄÌص㣬ÄǾÍÊÇÓжàÖÖÒýÇæ¿ÉÒÔ¹©ÄãÑ¡Ôñ¡£Èç¹ûÈü
³µÊÖÄܸù¾Ý²»Í¬µÄ·¿ö£¬µØÐÎËæÊÖ¸ü»»ÓëÖ®×îÊÊÒ˵ÄÒýÇ棬ÄÇôËûÃǽ«´´ÔìÆæ¼£¡£È»¶øÄ¿Ç°ËûÃÇ»¹×ö²»µ½ÄÇÑù±ã½ÝµÄ¸ü»»ÒýÇ棬µ«ÊÇÎÒÃÇÈ´¿ÉÒÔ£¡
     Ëù ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ