Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö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 »ù±¾ÃüÁî

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 -p mysql
               mysql>UPDATE user SET password=PASSWORD("new") WHERE user='root';
               mysql>flush privileges;
5
¡¢É¾³ýÄäÃûÓû§
delete from mysql.user where user='';
6
¡¢²é¿´ÏµÍ³ÒÑ´æÔÚµÄÊý¾Ý¿â
show databases;
7¡¢É¾³ýÃûΪtestµÄ¿ÕÊý¾Ý¿â
drop database test;
8¡¢½¨Á¢mysqlÓû§
  Àýa:
½¨Á¢¶ÔtestÊý¾Ý¿âÓÐÍêÈ«²Ù×÷ȨÏÞµÄÃûΪcentospubµÄÓû§
mysql>grant all privileges on test.* to centospub@localhost identified by 'password';
  Àýb:
Ôö¼ÓÒ»¸öÓû§test1ÃÜÂëΪabc£¬ÈÃËû¿ÉÒÔÔÚÈκÎÖ÷»úÉϵǼ£¬²¢¶ÔËùÓÐÊý¾Ý¿âÓвé ......

MySQL Master/Slave Server ¼ÜÉè



»·¾³£ºÁ½Ì¨·þÎñÆ÷IP:192.168.30.57\192.168.30.58
1¡¢ÏÂÔØmysql-5.0.86-linux-i686-glibc23.tar.gz µ½http://dev.mysql.com/downloads/mysql/5.0.html#linuxÏÂÔØ
2¡¢½âѹ tar -zxvf
mysql-5.0.86-linux-i686-glibc23.tar.gz
3¡¢´´½¨Á´½Ó ln -s
mysql-5.0.86-linux-i686-glibc23
mysql
4¡¢½øÈëmysql
Ŀ¼Ï cd mysql
5£ºÐ½¨ mysql Óû§×é
 groupadd mysql
6£ºÐ½¨ mysqlÓû§²¢ÊôÓÚmysqlÓû§×é
 useradd -g mysql mysql
7£ºÖ´Ðа²×°½Å±¾£º
   scripts/mysql_install_db --user=mysql
8£º¸Ä±äÊô×é  (×¢ÒâСÊýµã)
   chown -R root  . (×¢ÒâСÊýµã)
9£º¸Ä±äÊý¾ÝÊô×é
 chown -R mysql data
10£ºÊäÈëÃüÁî  chgrp -R mysql . (×¢ÒâСÊýµã)
11¡¢¿½±´ÅäÖÃÎļþ cp supports-files/my-lagre.cnf /etc/my.cnf
12¡¢Æô¶¯mysql
bin/mysqld_safe -user=root &
13¡¢µÇ¼ bin/mysql
-uroot -p
Ò»¡¢Master Server ·½Ãæ
A.É趨 Server-id
Ê×ÏÈÒªÉ趨 server-id¡£»ù±¾ÉÏûÓÐʲôÌرðµÄÏÞÖÆ£¬Ö»Òª Master ºÍ Slave µÄ server-id ²»Ò»Ñù¼´¿É£¬µ«ÆäÖµ±ØÐèΪ
1 ÖÁ ......

mysqlÃÜÂëÍü¼ÇµÄÐ޸ķ½·¨

1¡¢ÔÚlinuxÏ£º
     ²é¿´mysql ÊÇ·ñÔËÐУºps -ef | grep myslq
     Èç¹û MySQL ÕýÔÚÔËÐУ¬Ê×ÏÈɱ֮: kill mysqlµÄ½ø³ÌºÅ¡£
¡¡¡¡Æô¶¯ MySQL :/usr/bin/safe_mysqld --skip-grant-tables &
¡¡¡¡¾Í¿ÉÒÔ²»ÐèÒªÃÜÂë¾Í½øÈë MySQL ÁË¡£
¡¡¡¡È»ºó¾ÍÊÇ
¡¡¡¡>use mysql
¡¡¡¡>update user set password=password("new_pass") where user="root";
¡¡¡¡>flush privileges;
¡¡¡¡ÖØÐÂɱ MySQL £¬ÓÃÕý³£·½·¨Æô¶¯ MySQL ¡£
2¡¢ÔÚwindowsÏ£º
    1.Æô¶¯Mysql·þÎñ:´ò¿ªCMD,ÊäÈënet start mysql
    2.½øÈëmysqlĿ¼ÏµÄbinĿ¼
    3.ÔËÐÐmysqld-nt --skip-grant-tables(ÀÏ°æ±¾¿ÉÒÔÊÇmysqld --skip-grant-tables)À´Ìø¹ýÊÚȨ±íµÄÑéÖ¤,ÕâÑùÎÒÃǾͿÉÒÔÖ±½ÓµÇ½     MySQL·þÎñÆ÷£¬È»ºóÔÙÐÞ¸ÄrootÓû§µÄ¿ÚÁÖØÆôMySQL¾Í¿ÉÒÔÓÃпÚÁîµÇ½ÁË¡£
    4.MySqlÃÜÂëÖªµÀ£¬µ«ÊÇÓÃMySql-FrontÁ¬½Ó²»ÉÏÈ¥ÓÐÕâÑùÒ»Ì×Á¬½ÓMySqlÊý¾Ý¿âµÄϵͳ£¬Ö»Òª¸ÄÁËrootµÄÃÜÂ룬ÓÃMySql-FrontÁ¬½Ó¾ÍÁ¬½Ó²»ÉÏÈ¥ÁË£¬ÕâʱҪÊÇÏë¸ÄÃÜÂëµÄ»°¾ÍҪʹÓÃÕâÖÖ·½·¨ÁË£¬ÔÚ°²×°MyS ......

mysqlË÷ÒýµÄʹÓü°Óï¾äÓÅ»¯

Ò»:mysqlÀïÄ¿Ç°Ö»Ö§³Ö4ÖÖË÷Òý·Ö±ðÊÇ:b-tree,full-text,hashÒÔ¼°r-treeË÷Òý b-treeË÷ÒýÓ¦¸ÃÊÇmysqlÀï×î¹ã·ºµÄË÷ÒýµÄÁË,³ýÁËarchive,»ù±¾ËùÓеĴ洢ÒýÇ涼֧³ÖËü. 1.b-treeÔÚmyisamÀïµÄÐÎʽºÍinnodbÉÔÓв»Í¬ ÔÚinnodbÀïÃæÓÐÁ½ÖÖÐÎ̬:ÆäÒ»ÊÇprimary keyÐÎ̬Æäleaf nodeÀï´æ·ÅµÄÊÇÊý¾Ý.¶øÇÒ²»½ö´æ·ÅÁËË÷Òý¼üµÄÊý¾Ý,»¹´æ·ÅÁËÆäËû×ֶεÄÊý¾Ý.Æä¶þÊÇsecondary index,Æäleaf nodeºÍÆÕͨµÄb-tree²î²»¶à,Ö»ÊÇ»¹´æ·ÅÁËÖ¸ÏòÖ÷¼üµÄÐÅÏ¢. ¶øÔÚmyisamÀï,Ö÷¼üºÍÆäËûµÄ²¢Ã»ÓÐÌ«´óÇø±ð.²»¹ýºÍinnodb²»Ì«Ò»ÑùµÄµØ·½ÊÇ,ÔÚmyisamÀï,leaf nodeÀï´æ·ÅµÄ²»ÊÇÖ÷¼üµÄÐÅÏ¢,´æµÄÊÇÖ¸ÏòÊý¾ÝÎļþÀïµÄ¶ÔÓ¦Êý¾ÝÐеÄÐÅÏ¢. 2.hashË÷Òý,Ä¿Ç°ÎÒËùÖªµÀµÄ¾ÍÖ»ÓÐmemoryºÍndb clusterÖ§³ÖÕâÖÖË÷Òý. hashË÷ÒýÓÉÓÚÆä½á¹¹,ËùÒÔÔÚÿ´Î²éѯµÄʱºòÖ±½ÓÒ»´Îµ½Î»²»ÐÐb-treeÄÇÑù,Ò»µãµãµÄÇ°½ø,ËùÒÔhashË÷ÒýµÄЧÂʸßÓÚb-tree.µ«hashÒ²ÓÐȱµã,Ö÷ÒªÈçÏÂ: (1)ÓÉÓÚ´æ·ÅµÄÊÇhashÖµ,ËùÒÔ½öÖ§³Ö<=>ÒÔ¼°in²Ù×÷. (2)hashË÷ÒýÎÞ·¨Í¨¹ý²Ù×÷Ë÷ÒýÀ´ÅÅÐò,ÕâÊÇÒòΪ´æ·ÅµÄʱºò¾­¹ýhash¼ÆËã,µ«ÊǼÆËãµÄhashÖµºÍ´æ·ÅµÄ²»Ò»¶¨ÏàµÈ,ËùÒÔÎÞ·¨ÅÅÐò. (3)ÔÚ×éºÏËùÒÔÀï,ÎÞ·¨¶Ô²¿·ÖʹÓÃË÷Òý. (4)²»ÄܱÜÃâÈ«±íɨÃè,Ö»ÊÇÓÉÓÚÔÚmemory±íÀïÖ§³Ö· ......

MySQLÊý¾Ý¿â²Ù×÷ÖÐÎÄÂÒÂë

½â¾öÂÒÂë×îºÃµÄ·½·¨ÊÇÔÚÏîÄ¿Éè¼ÆÖ®³õ£¬Í³Ò»ËùÓеÄ×Ö·û¼¯£¬ÀýÈçÒ³Ãæ¡¢request¶ÔÏóÒÔ¼°Êý¾Ý¿âµÈµÈ¡£
Ò»¡¢ ¼¸ÖÖ³£¼ûµÄÂÒÂëÏÖÏó£º
1¡¢Ò³ÃæÂÒÂë
    µ¥´¿µÄÒ³ÃæÂÒÂëÊǺܺýâ¾öµÄ£¬Ö»ÒªÐÞ¸ÄÍ·²¿ÊʺϵÄ×Ö·û¼¯¼´¿É£¬Èç¹ûÒ³ÃæÖÐÎÄÏÔʾÂÒÂ룬Äã¿ÉÒÔ°Ñ×Ö·û¼¯ÐÞ¸ÄΪ£ºgb2312»ògbk¡£
2¡¢Ò³ÃæÖ®¼ä´«µÝµÄ²ÎÊýÊÇÂÒÂë
   Ò³ÃæÖ®¼ä´«µÝ²ÎÊý³öÏÖµÄÂÒÂ룬¾ÍÒª½â¾öÒ³Ãæ±àÂëºÍrequsetµÄ×Ö·û¼¯ÎÊÌ⣬ÔÚ²ÎÊý´«½ø´«³öʱÖØÐÂÉèÖÃÏàÓ¦µÄ×Ö·û¼¯¡£±ÈÈ磺request.setCharacterEncoding("UTF-8");
3¡¢Êý¾Ý¿âÂÒÂ루ÏÂÃæÏêϸ½éÉÜ£©
¶þ¡¢Êý¾Ý¿âÂÒÂë½â¾ö·½·¨£¨Mysql£©
   Ò³ÃæºÍÒ³Ãæ´«Öµ¶¼Ã»ÓÐÎÊÌ⣬½á¹û·¢ÏÖ´æ´¢ÔÚÊý¾Ý¿âÖеÄÊý¾Ý³öÏÖÁËÂÒÂ룬ÔòÎÊÌâÊdzöÏÖÔÚÊý¾Ý¿âµÄ±àÂëÎÊÌâ¡£
   ÏÂÃæÎÒÒÑMySqlÊý¾Ý¿âΪÀý˵Ã÷½â¾ö·½·¨£º
    Èç¹ûÄã°²×°Êý¾Ý¿âµÄʱºò×Ö·û¼¯Ê¹ÓõÄĬÈÏÑ¡Ïlatin1
    DOSÃüÁîϽøÈëÊý¾Ý¿âshow Ò»ÏÂ×Ö·û¼¯£¨ÃüÁshow variables like"%char%"; £©ÏÔʾÈçÏ£º
Java´úÂë
+--------------------------+---------------+   
| Variable_name     &nb ......

MySQLÊý¾Ý¿âµÄ»ù±¾²Ù×÷ÃüÁî

Ò»¡¢mysql·þÎñ²Ù×÷
1¡¢net start mysql //Æô¶¯mysql·þÎñ
2¡¢net stop mysql //Í£Ö¹mysql·þÎñ¡¡
3¡¢mysql -hÖ÷»úµØÖ· -uÓû§Ãû £­pÓû§ÃÜÂë //½øÈëmysqlÊý¾Ý¿â
4¡¢quit //Í˳ömysql²Ù×÷
5¡¢mysqladmin -uÓû§Ãû -p¾ÉÃÜÂë password ÐÂÃÜÂë //¸ü¸ÄÃÜÂë
6¡¢grant select on Êý¾Ý¿â.* to Óû§Ãû@µÇ¼Ö÷»ú identified by "ÃÜÂë" //Ôö¼ÓÐÂÓû§
exemple:
Àý2¡¢Ôö¼ÓÒ»¸öÓû§test2ÃÜÂëΪabc,ÈÃËûÖ»¿ÉÒÔÔÚlocalhostÉϵǼ£¬²¢¿ÉÒÔ¶ÔÊý¾Ý¿âmydb½øÐвéѯ¡¢²åÈë¡¢Ð޸ġ¢É¾³ýµÄ²Ù×÷
£¨localhostÖ¸±¾µØÖ÷»ú£¬¼´MYSQLÊý¾Ý¿âËùÔÚµÄÄÇ̨Ö÷»ú£©£¬ÕâÑùÓû§¼´Ê¹ÓÃÖªµÀtest2µÄÃÜÂ룬ËûÒ²ÎÞ·¨´ÓinternetÉÏÖ±½Ó·ÃÎÊÊý¾Ý
¿â£¬Ö»ÄÜͨ¹ýMYSQLÖ÷»úÉϵÄwebÒ³À´·ÃÎÊÁË¡£
grant select,insert,update,delete on mydb.* to test2@localhost identified by "abc";
Èç¹ûÄã²»Ïëtest2ÓÐÃÜÂ룬¿ÉÒÔÔÙ´òÒ»¸öÃüÁÃÜÂëÏûµô¡£
grant select,insert,update,delete on mydb.* to test2@localhost identified by "";
¶þ¡¢Êý¾Ý¿â²Ù×÷
1¡¢show databases; //ÁгöÊý¾Ý¿â
2¡¢use database_name //ʹÓÃdatabase_nameÊý¾Ý¿â
3¡¢create database data_name //´´½ ......
×ܼǼÊý:2220; ×ÜÒ³Êý:370; ÿҳ6 Ìõ; Ê×Ò³ ÉÏÒ»Ò³ [359] [360] [361] [362] 363 [364] [365] [366] [367] [368]  ÏÂÒ»Ò³ βҳ
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ