10.表的數據更新
(1)一次修改一個字段,再次注意語法。文本需要加引號但數字不要。
mysql>update table01 set field03='new info'swheresfield01=1;
query ok, 1 row affected (0.00 sec)
(2)一次改變多個字段,記住在每一個更新的字段間用逗號隔開。
mysql>update table01 set field04=19991022, field05=062218swheresfield01=1;
query ok, 1 row affected (0.00 sec)
(3)一次更新多個數據
mysql>update table01 set field05=152901swheresfield04>19990101;
query ok, 3 rows affected (0.00 sec)
11.刪除數據
mysql>delete from table01swheresfield01=3;
query ok, 1 row affected (0.00 sec)
12.導入數據庫表
(1)創建.sql文件
(2)先產生一個庫如auction.c:mysqlin>mysqladmin -u root -p creat auction,會提示輸入密碼,然后成功創建。
(3)導入auction.sql文件
c:mysqlin>mysql -u root -p auction < auction.sql。
通過以上操作,就可以創建了一個數據庫auction以及其中的一個表auction。
13.mysql數據庫的授權
mysql>grant select,insert,delete,create,drop
on *.* (或test.*/user.*/..)
to用戶名@localhost
identified by '密碼';
如:新建一個用戶帳號以便可以訪問數據庫,需要進行如下操作:
mysql> grant usage
-> on test.*
-> to [email protected];
query ok, 0 rows affected (0.15 sec)
此后就創建了一個新用戶叫:testuser,這個用戶只能從localhost連接到數據庫并可以連接到test數據庫。下一步,我們必須指定 testuser這個用戶可以執行哪些操作:
mysql> grant select, insert, delete,update
-> on test.*
-> to [email protected];
query ok, 0 rows affected (0.00 sec)
此操作使testuser能夠在每一個test數據庫中的表執行select,insert和delete以及update查詢操作?,F在我們結束操作并退出mysql客戶 程序:
mysql> exit
bye
14.授權mysql用戶密碼
mysql數據庫的默認用戶名為"root"(ms sql server的sa相似),密碼默認為空。在dos提示符(注意,不是mysql提示符)下輸入
c:mysqlin>"mysqladmin -u root -p password newpassword
回車后會提示你輸入原來的密碼,由于原來密碼為空,直接回車,root用戶的密碼便改為"newpassword"了。
新聞熱點
疑難解答