Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB
ÈÈÃűêÇ©£º c c# c++ asp asp.net linux php jsp java vb Python Ruby mysql sql access Sqlite sqlserver delphi javascript Oracle ajax wap mssql html css flash flex dreamweaver xml
 ×îÐÂÎÄÕ : mysql

MySQL grant Óï·¨µÄÏêϸ½âÎö

ÒÔϵÄÎÄÕÂÊÇMySQL grantÓï·¨µÄÏêϸ½âÎö£¬Èç¹ûÄã¶ÔMySQL grantÓï·¨µÄÏà¹ØµÄʵ¼Ê²Ù×÷ÓÐÐËȤµÄ»°£¬Äã¾Í¿ÉÒÔ¶ÔÒÔϵÄÎÄÕµã»÷¹Û¿´ÁË¡£ÎÒÃÇ´ó¼Ò¶¼ÖªµÀMySQLÊý¾Ý¿â¸³ÓèÓû§È¨ÏÞÃüÁîµÄ¼òµ¥¸ñʽ¿É¸ÅÀ¨Îª£º
grant ȨÏÞ on Êý¾Ý¿â¶ÔÏó to Óû§
Ò»¡¢grant ÆÕͨÊý¾ÝÓû§£¬²éѯ¡¢²åÈë¡¢¸üС¢É¾³ý Êý¾Ý¿âÖÐËùÓбíÊý¾ÝµÄȨÀû¡£
grant select on testdb.* to common_user@'%';
grant insert on testdb.* to common_user@'%';
grant update on testdb.* to common_user@'%';
grant delete on testdb.* to common_user@'%';
»òÕߣ¬ÓÃÒ»Ìõ MySQL ÃüÁîÀ´Ìæ´ú£º
grant select,insert,update,delete on testdb.* to common_user@'%'
¶þ¡¢grant Êý¾Ý¿â¿ª·¢ÈËÔ±£¬´´½¨±í¡¢Ë÷Òý¡¢ÊÓͼ¡¢´æ´¢¹ý³Ì¡¢º¯Êý¡£¡£¡£µÈȨÏÞ¡£
grant ´´½¨¡¢Ð޸ġ¢É¾³ý MySQL Êý¾Ý±í½á¹¹È¨ÏÞ¡£
grant create on testdb.* to developer@'192.168.0.%';
grant alter on testdb.* to developer@'192.168.0.%';
grant drop on testdb.* to developer@'192.168.0.%';
grant ²Ù×÷ MySQL Íâ¼üȨÏÞ¡£
grant references on testdb.* to developer@'192.168.0.%';
grant ²Ù×÷ MySQL ÁÙʱ±íȨÏÞ¡£
grant create temporary ......

¸øÄãµÄMySqlÊÜÔ¶³Ì·ÃÎÊȨÏÞ

¸ømysql¿ªÒ»¸ö¿ÉÒÔÔ¶³Ì·ÃÎʵÄÓû§ÃüÁîÈçÏÂ:
GRANT ALL PRIVILEGES ON *.* TO 'myuser'@'%' IDENTIFIED BY 'mypassword' WITH GRANT OPTION;
"*.*" ±íʾÊý¾Ý¿âÖÐËùÓеıí,Ò²¿ÉÒÔ»»³ÉÖ¸¶¨µÄ±íÈçtest.*
"myuser" ±íʾµÄÊÇ·ÃÎʵÄÓû§Ãû;
"%" ±íʾËùÓеÄÖ÷»ú¼´ÈκεÄÖ÷»ú¶¼¿ÉÒÔͨ¹ýÕâ¸öÓû§Ãû·ÃÎÊÎÒµÄÊý¾Ý¿â,Ò²¿ÉÒԸóÉÌض¨µÄipµØÖ·.Èç"192.168.1.2";
"mypassword" ±íʾµÄ¾ÍÊÇÃÜÂëÁË ......

mysqlÐÔÄÜÓÅ»¯


¾¡¿ÉÄܵØʹÓÃ×îÓÐЧ(×îС)µÄÀàÐÍ¡£MySQLÓкܶà½ÚÊ¡´ÅÅÌ¿Õ¼äºÍÄÚ´æµÄרҵ»¯ÀàÐÍ¡£
Èç¹û¿ÉÄÜʹ±í¸üС£¬Ê¹ÓýÏСµÄÕûÊýÀàÐÍ¡£ÀýÈ磬MEDIUMINT¾­³£±ÈINTºÃһЩ¡£
Èç¹û¿ÉÄÜ£¬ÉùÃ÷ÁÐΪNOT NULL¡£ËüʹÈκÎÊÂÇé¸ü¿ì¶øÇÒÄãΪÿÁнÚʡһλ¡£×¢ÒâÈç¹ûÔÚÄãµÄÓ¦ÓóÌÐòÖÐÄãȷʵÐèÒªNULL£¬ÄãÓ¦¸ÃºÁÎÞÒÉÎÊʹÓÃËü£¬Ö»ÊDZÜÃâȱʡµØÔÚËùÓÐÁÐÉÏÓÐËü¡£
Èç¹ûÄãûÓÐÈκα䳤ÁÐ(VARCHAR¡¢TEXT»òBLOBÁÐ)£¬Ê¹Óù̶¨³ß´çµÄ¼Ç¼¸ñʽ¡£Õâ±È½Ï¿ìµ«ÊDz»ÐҵؿÉÄÜ»áÀË·ÑһЩ¿Õ¼ä¡£
ÿÕűíÓ¦¸ÃÓо¡¿ÉÄ̵ܶÄÖ÷Ë÷Òý¡£ÕâʹһÐеıæÈÏÈÝÒ׶øÓÐЧ¡£
¶Ôÿ¸ö±í£¬Äã±ØÐë¾ö¶¨Ê¹ÓÃÄÄÖÖ´æ´¢/Ë÷Òý·½·¨¡£
Ö»´´½¨ÄãȷʵÐèÒªµÄË÷Òý¡£Ë÷Òý¶Ô¼ìË÷Óкô¦µ«Êǵ±ÄãÐèÒª¿ìËÙ´æ´¢¶«Î÷ʱ¾Í±äµÃÔã¸â¡£Èç¹ûÄãÖ÷Ҫͨ¹ýËÑË÷ÁеÄ×éºÏÀ´´æÈ¡Ò»¸ö±í£¬ÒÔËüÃÇ×öÒ»¸öË÷Òý¡£µÚÒ»¸öË÷Òý²¿·ÖÓ¦¸ÃÊÇ×î³£ÓõÄÁС£Èç¹ûÄã×ÜÊÇʹÓÃÐí¶àÁУ¬ÄãÓ¦¸ÃÊ×ÏÈÒÔ¸ü¶àµÄ¸±±¾Ê¹ÓÃÁÐÒÔ»ñµÃ¸üºÃµÄÁÐË÷ÒýѹËõ¡£
Èç¹ûºÜ¿ÉÄÜÒ»¸öË÷ÒýÔÚÍ·¼¸¸ö×Ö·ûÉÏÓÐΨһµÄǰ׺£¬½ö½öË÷Òý¸Ãǰ׺±È½ÏºÃ¡£MySQLÖ§³ÖÔÚÒ»¸ö×Ö·ûÁеÄÒ»²¿·ÖÉϵÄË÷Òý¡£¸ü¶ÌµÄË÷Òý¸ü¿ì£¬²»½öÒòΪËûÃÇÕ¼½ÏÉٵĴÅÅÌ¿Õ¼ä¶øÇÒÒòΪËûÃǽ«ÔÚË÷Òý»º´æÖиøÄã¸ü¶àµÄÃüÖÐÂʲ¢ÇÒÒò´ËÓиüÉÙ´ÅÅÌÑ°µÀ¡£
ÔÚһЩÇéÐ ......

MySQL replace into Ó÷¨


ÔÚÏò±íÖвåÈëÊý¾ÝµÄʱºò£¬¾­³£Óöµ½ÕâÑùµÄÇé¿ö£º1. Ê×ÏÈÅжÏÊý¾ÝÊÇ·ñ´æÔÚ£» 2. Èç¹û²»´æÔÚ£¬Ôò²åÈ룻3.Èç¹û´æÔÚ£¬Ôò¸üС£
ÔÚ SQL Server ÖпÉÒÔÕâÑù´¦Àí£º
if not exists (select 1 from t where id = 1) insert into t(id, update_time) values(1, getdate()) else update t set update_time = getdate() where id = 1
ÄÇô MySQL ÖÐÈçºÎʵÏÖÕâÑùµÄÂß¼­ÄØ£¿±ð׿±£¡MySQL ÖÐÓиü¼òµ¥µÄ·½·¨£º replace into
replace into t(id, update_time) values(1, now());
»ò
replace into t(id, update_time) select 1, now();
replace into ¸ú insert ¹¦ÄÜÀàËÆ£¬²»Í¬µãÔÚÓÚ£ºreplace into Ê×Ïȳ¢ÊÔ²åÈëÊý¾Ýµ½±íÖУ¬ 1. Èç¹û·¢ÏÖ±íÖÐÒѾ­ÓдËÐÐÊý¾Ý£¨¸ù¾ÝÖ÷¼ü»òÕßΨһË÷ÒýÅжϣ©ÔòÏÈɾ³ý´ËÐÐÊý¾Ý£¬È»ºó²åÈëеÄÊý¾Ý¡£ 2. ·ñÔò£¬Ö±½Ó²åÈëÐÂÊý¾Ý¡£
ҪעÒâµÄÊÇ£º²åÈëÊý¾ÝµÄ±í±ØÐëÓÐÖ÷¼ü»òÕßÊÇΨһË÷Òý£¡·ñÔòµÄ»°£¬replace into »áÖ±½Ó²åÈëÊý¾Ý£¬Õ⽫µ¼Ö±íÖгöÏÖÖظ´µÄÊý¾Ý¡£
MySQL replace into ÓÐÈýÖÖÐÎʽ£º
1. replace into tbl_name(col_name, ...) values(...) 2. replace into tbl_name(col_name, ...) select ... 3. replace into tbl_name set ......

MySQL³£ÓÃÃüÁî

1. ¸øroot¼ÓÃÜÂ룺/usr/bin/mysqladmin -u root password 123456
2. µ¼³ö£ºmysqldump -u root -p dbname > file.sql
3. µ¼È룺mysql -u root -p dbname < backup-file.sql
4. ÊÚȨ£ºgrant all on *.* to root@"%" identified by "ÃÜÂë";
5. ÊÕ»ØȨÏÞ£ºrevoke all privileges on *.* from root@"%";
6. µÇ¼£ºmysql -u root -p
7. ²é¿´Êý¾Ý¿â£ºshow databases;
8. ʹÓÃÊý¾Ý¿â£ºuse test;
9. ²é¿´±í£ºshow tables; ......

java¶ÁÈ¡mysqlÊý¾Ý¿âlatin1±ÜÃâÂÒÂë·½·¨

дÈëʱ£¬ÏÈ×öencode£º
public static String encode(String src) {
String result = null;
try {
result = new String(src.getBytes("gbk"), "ISO-8859-1");
} catch (UnsupportedEncodingException uee) {
System.err.println(uee);
}
return result;
}
¶Á³öʱ£¬ÔÙ×ödecode£º
public static String decode(String src) {
String result = null;
try {
result = new String(src.getBytes("ISO-8859-1"), "gbk");
} catch (UnsupportedEncodingException uee) {
System.err.println(uee);
}
return result;
}
Á¬½Óʱ²»ÐèÒªÖ¸¶¨×Ö·û¼¯ ......

java¶ÁÈ¡mysqlÊý¾Ý¿âlatin1±ÜÃâÂÒÂë·½·¨

дÈëʱ£¬ÏÈ×öencode£º
public static String encode(String src) {
String result = null;
try {
result = new String(src.getBytes("gbk"), "ISO-8859-1");
} catch (UnsupportedEncodingException uee) {
System.err.println(uee);
}
return result;
}
¶Á³öʱ£¬ÔÙ×ödecode£º
public static String decode(String src) {
String result = null;
try {
result = new String(src.getBytes("ISO-8859-1"), "gbk");
} catch (UnsupportedEncodingException uee) {
System.err.println(uee);
}
return result;
}
Á¬½Óʱ²»ÐèÒªÖ¸¶¨×Ö·û¼¯ ......
×ܼǼÊý:2220; ×ÜÒ³Êý:370; ÿҳ6 Ìõ; Ê×Ò³ ÉÏÒ»Ò³ [8] [9] [10] [11] 12 [13] [14] [15] [16] [17]  ÏÂÒ»Ò³ βҳ
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ