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

MySQL³£ÓÃÃüÁîÓë»ù±¾ÃüÁî²Ù×÷


1¡¢MySQL³£ÓÃÃüÁî ­
­
create database name; ´´½¨Êý¾Ý¿â ­
­
use databasename; Ñ¡ÔñÊý¾Ý¿â ­
­
drop database name Ö±½Óɾ³ýÊý¾Ý¿â£¬²»ÌáÐÑ ­
­
show tables; ÏÔʾ±í ­
­
describe tablename; ±íµÄÏêϸÃèÊö ­
­
select ÖмÓÉÏdistinctÈ¥³ýÖظ´×ֶΠ­
­
mysqladmin drop databasename ɾ³ýÊý¾Ý¿âÇ°£¬ÓÐÌáʾ¡£ ­
­
ÏÔʾµ±Ç°mysql°æ±¾ºÍµ±Ç°ÈÕÆÚ ­
­
select version(),current_date; ­
­
2¡¢ÐÞ¸ÄmysqlÖÐrootµÄÃÜÂ룺 ­
­
shell>mysql -u root -p ­
­
mysql> update user set password=password(”xueok654123″) where user=’root’; ­
­
mysql> flush privileges //Ë¢ÐÂÊý¾Ý¿â ­
­
mysql>use dbname£» ´ò¿ªÊý¾Ý¿â£º ­
­
mysql>show databases; ÏÔʾËùÓÐÊý¾Ý¿â ­
­
mysql>show tables; ÏÔʾÊý¾Ý¿âmysqlÖÐËùÓÐµÄ±í£ºÏÈuse mysql£»È»ºó ­
­
mysql>describe user; ÏÔʾ±ímysqlÊý¾Ý¿âÖÐuser±íµÄÁÐÐÅÏ¢£©£» ­
­
3¡¢grant ­
­
´´½¨Ò»¸ö¿ÉÒÔ´ÓÈκεط½Á¬½Ó·þÎñÆ÷µÄÒ»¸öÍêÈ«µÄ³¬¼¶Óû§£¬µ«ÊDZØÐëʹÓÃÒ»¸ö¿ÚÁîsomething×öÕâ¸ö ­
­
mysql> grant all privileges on *.* to user@localhost identified by ’something’ with ­
­
Ôö¼ÓÐÂÓû§ ­
­
¸ñʽ£ºgrant select on Êý¾Ý¿â.* to Óû§Ãû@µÇ¼Ö÷»ú identified by “ÃÜÂë” ­
­
GRANT ALL PRIVILEGES ON *.* TO monty@localhost IDENTIFIED BY ’something’ WITH GRANT OPTION; ­
­
GRANT ALL PRIVILEGES ON *.* TO monty@”%” IDENTIFIED BY ’something’ WITH GRANT OPTION; ­
­
ɾ³ýÊÚȨ£º ­
­
mysql> revoke all privileges on *.* from root@”%”; ­
­
mysql> delete from user where user=”root” and host=”%”; ­
­
mysql> flush privileges; ­
­
´´½¨Ò»¸öÓû§customÔÚÌض¨¿Í»§¶Ëit363.comµÇ¼£¬¿É·ÃÎÊÌض¨Êý¾Ý¿âfangchandb ­
­
mysql >grant select, insert, update, delete, create,drop on fangchandb.* to custom@ it363.c


Ïà¹ØÎĵµ£º

MysqlÖÐcount(*),DISTINCTµÄʹÓ÷½·¨ºÍЧÂÊÑо¿

ÔÚ´¦ÀíÒ»¸ö´óÊý¾ÝÁ¿Êý¾Ý¿âµÄʱºò
ͻȻ·¢ÏÖmysql¶ÔÓÚcount(*)µÄ²»Í¬´¦Àí»áÔì³É²»Í¬µÄ½á¹û
±ÈÈçÖ´ÐÐ
SELECT count(*) from tablename
¼´Ê¹¶ÔÓÚǧÍò¼¶±ðµÄÊý¾ÝmysqlÒ²Äܷdz£Ñ¸Ëٵķµ»Ø½á¹û
¶ø¶ÔÓÚ
SELECT count(*) from tablename WHERE…..
mysqlµÄ²éѯʱ¼ä¿ªÊ¼ÅÊÉý
×Ðϸ²éÔÄÀÛÏÂÊÖ²á,·¢ÏÖµ±Ã»ÓÐWHEREÓï¾ä¶ÔÓÚÕ ......

mysqlÃüÁîÐÐ HAVING×Ó¾ä UNION

ÎÒÔÚmysql ÃüÁîÐÐÕâ¸öϵÁÐÀï½éÉܹýÓÐÌõ¼þ²éѯ£¬ËüÓõ½WHERE×Ӿ䡣µ«ÊÇÓÐʱºòÓÃWHERE×Ó¾äÎÞ·¨¸øÎÒÃǵIJéѯ¼ÓÈëÌõ¼þ£¬±ÈÈçÔÚÉÏÒ»½ÚÎÒÃÇѧϰµÄGROUP BY(°´×é¹éÀà)×Ӿ䣬Èç¹ûÎÒÃÇÒªÔÚ°´×é¹éÀàºó¼ÓÈëÌõ¼þ£¬ÓÃWHERE¾ÍÐв»Í¨£¬ÒòΪWHEREÖ»¿ÉÒÔÔÚ°´×é¹éÀàÇ°¼ÓÈëÌõ¼þ¡£ºÃÔÚmysqlÌṩHAVING×Ӿ䣬Ëü¿ÉÒÔ°ïÎÒÃǽâ¾öÕâ¸öÎÊÌâ¡£
ÈçºÎÊ¹Ó ......

MySQL collation·½·¨

ÎÊÌâÊÇÕâÑùµÄ£º
Ò»ÕÅtestµÄ±í£¬×Ö·û¼¯²ÉÓõÄlatin1¡£
select to_id from test where to_id='cnÏó_Íõ';
+---------------+
| to_id |
+---------------+
| cnÌÕ_ÌÕ |
| cnÏó_Íõ |
+---------------+
2 rows in set (0.00 sec)
È¡cnÏó_ÍõµÄÊý¾Ý,¾ÓÈ»°ÑcnÌÕ_ÌÕµÄÊý¾ÝҲȡ»ØÀ´ÁË¡£
ÕâÏÔÈ»ÊDz»ÔÊÐíµÄ¡£
......

tomcat ÅäÖÃmysql Êý¾Ý¿âÁ¬½Ó³Ø

tomcat °²×°Ä¿Â¼ÏµÄconfĿ¼ÖеÄcontext.xmlÓëweb.xmlÎļþ·Ö±ðÐÞ¸ÄÈçÏ£º
context.xml мÓÈçÏÂÄÚÈÝ£º
<Resource name="jdbc/mysql"
auth="Container"
type="javax.sql.DataSource"
driverClassName="com.mysql.jdbc.Driver"
url="jdbc:mysql://Êý¾Ý¿âµØÖ·:3306/Êý¾Ý¿âà ......

linuxÏÂcÓïÑÔÁ¬½ÓmysqlÊý¾Ý¿â

ÔÚFC8ÖÐĬÈÏ°²×°µÄÓÐmysql£¬Ã»ÓеĻ°¿ÉÒԺܷ½±ãµÄ°²×°Ï¡£
ĬÈϵÄmysqlµÄincludeÎļþĿ¼ÔÚ/usr/include/mysql
ĬÈϵÄmysqlµÄlibÎļþ¼ÐÔÚ/usr/lib/mysql
ÕâÁ½¸öĿ¼ÔÚÎÒÃDZàÒëʱºòÐèÒªµ½¡£
ÎҵIJâÊÔÓõÄC´úÂëΪ£º
££include <stdio.h>
#include <stdlib.h>
#include <mysql.h>
#define CONN_HOST ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ