MYSQL常ç??/a>?½ä»¤
1.导å?ºæ?´ä¸ª?°æ??/a>åº?
mysqldump -u ?¨æ?·å?? -p --default-character-set=latin1 ?°æ????? > 导å?ºç????ä»?/a>??(?°æ???é»?认ç?????atin1)
mysqldump -u wcnc -p smgp_apps_wcnc > wcnc.sql
2.导å?ºä?ä¸?¡¨
mysqldump -u ?¨æ?·å?? -p ?°æ????? 表å??> 导å?ºç????件å??
mysqldump -u wcnc -p smgp_apps_wcnc users> wcnc_users.sql
3.导å?ºä?ä¸??°æ???ç»???
mysqldump -u wcnc -p -d ??add-drop-table smgp_apps_wcnc >d:wcnc_db.sql
-d 没æ???°æ? ??add-drop-table ?¨æ?ä¸?reateè¯??¥ä???å¢???ä¸?ä¸?rop table
4.导å?¥æ?°æ???
A:常ç??ource ?½ä»¤
è¿???ysql?°æ????§å?¶å?°ï?
�mysql -uroot-p
mysql>use ?°æ???
?¶å??使ç??ource?½ä»¤ï¼????¢å???°ä¸º????/a>??ä»?å¦?è¿????¨å?°ç??.sql)
mysql>source wcnc_db.sql
B:使ç??ysqldump?½ä»¤
mysqldump -u username -p dbname < filename.sql
C:使ç??ysql?½ä»¤
mysql -u username -p -D dbname < filename.sql
ä¸??????¨ä?????br /> 1??è¿???ySQLï¼?????ySQL Command Line Clientï¼?MySQL??DOS?????ï¼??´æ?¥è??¥å?è£??¶ç??å¯????³å????æ¤æ?¶ç????示ç????mysql>
2??????ySQLï¼?quit??exit
�??�??�
1??????建æ?°æ???
?½ä»¤ï¼?create database °æ?????>
ä¾?å¦?ï¼?建ç?ä¸?ä¸???ä¸?hkdb???°æ???
mysql> create database xhkdb;
2???¾ç¤º???????°æ???
?½ä»¤ï¼?show databases ï¼?注æ??ï¼???????ä¸?ï¼?
mysql> show databases;
3??????/a>?°æ???
?½ä»¤ï¼?drop database °æ?????>
ä¾?å¦?ï¼????¤å??ä¸ xhkdb???°æ???
mysql> drop database xhkdb;
4??è¿???/a>?°æ???
?½ä»¤ï¼? use °æ?????>
ä¾?å¦?ï¼?å¦???xhkdb?°æ???å????å°?è¯?å???å®?ï¼?
mysql> use xhkdb;
å±?å¹???示ï?Database changed
5???¥ç??å½???使ç?¨ç???°æ???
mysql> select database();
6??å½????°æ?????????è¡?a href="/heji/sjxxrj" target="_blank">ä¿¡æ??/a>ï¼?
mysql> show tables; ï¼?注æ??ï¼???????ä¸?ï¼?
ä¸???表æ??ä½?ï¼???ä½?ä¹???åº?è¿??¥æ??ä¸??°æ???
1??建表
?½ä»¤ï¼?create table <表å??> ( <å?段å??1> <ç±»å??1> [,..<å?段å??n> <ç±»å??n>]);
mysql> create table MyClass(
> id int(4) not null primary key auto_increment,
> name char(20) not null,
> sex int(4) not null default '0',
> degree double(16,2));
2???·å??表ç???
?½ä»¤ï¼? desc 表å??ï¼?????show columns from 表å??
mysql>DESCRIBE MyClass
mysql> desc MyClass;
mysql> show columns from MyClass;
3?????¤è¡¨
?½ä»¤ï¼?drop table <表å??>
ä¾?å¦?ï¼????¤è¡¨??ä¸ MyClass ??è¡?br /> mysql> drop table MyClass;
4?????¥æ?°æ??br /> ?½ä»¤ï¼?insert into <表å??> [( <å?段å??1>[,..<å?段å??n > ])] values ( ?? )[, ( ?? )]
ä¾?å¦?ï¼?å¾?è¡ MyClassä¸????¥ä??¡è?å½?, è¿?äº??¡è?å½?表示ï¼?ç¼??·ä¸º1????ä¸?om????绩为96.45, ç¼??·ä¸º2 ????ä¸?oan ????绩为82.99ï¼?ç¼??·ä¸º3 ????ä¸?ang ????绩为96.5.
mysql> insert into MyClass values(1,'Tom',96.45),(2,'Joan',82.99), (2,'Wang', 96.59);
5???¥è?表ä¸???°æ??br /> 1)???¥è?????è¡?
?½ä»¤ï¼? select <å?æ®?ï¼?å?æ®?ï¼?...> from < 表å?? > where < 表达å¼? >
ä¾?å¦?ï¼??¥ç??è¡ MyClass ä¸??????°æ?
?¸å?³æ??ç«?