windows下mysql命令_windows下的mysql命令使用
1、運(yùn)行-->cmd
c:\mysql\bin>?mysql?-h?localhost?-u?root?-p????(回車后有提示輸入密碼)
mysql>?QUIT/exit????????MYSQL數(shù)據(jù)庫連接與斷開;
2、mysql>?show?databases;????列出當(dāng)前服務(wù)器上存在的數(shù)據(jù)庫;
3、mysql>?create?database?blog;????創(chuàng)建一個新的數(shù)據(jù)庫blog;
4、mysql>?use?blog;????選取數(shù)據(jù)庫blog;
5、mysql>?show?tables;????????顯示數(shù)據(jù)庫中的所有數(shù)據(jù)表;
6、mysql>?create?table?user
->?(
->?id?int(4)?not?null?auto_inrement?primary?key,
->?name?varchar(20),
->?sex?char(1),
->birth?date);????????創(chuàng)建數(shù)據(jù)表user;
7、mysql>?describe?user;????查看數(shù)據(jù)表結(jié)構(gòu);
8、mysql>?select?name,sex,birth?from?user?order?by?sex,birth?desc;????按性別排序,再按生日倒序;
9、mysql>?select?distinct?sex?from?user;?????檢索出該字段中每個惟一的輸出記錄;
10、mysql>?select?max(birth)?as?birth?from?user;????????輸出最大值;
MIN(字段名)????????????????????????????????取得一個表格欄最小的值
AVG(字段名)???????????????????????????????得出一個表格欄平均值
COUNT(*|字段名)????????????????????????對數(shù)據(jù)行數(shù)的統(tǒng)計(jì)或?qū)δ骋粰谟兄档臄?shù)據(jù)行數(shù)統(tǒng)計(jì)
SUM(字段名)????????????????????????????????把數(shù)據(jù)欄的值相加
11、mysql>?select?sex,max(birth)?as?birth?from?user?group?by?sex;????按組查詢列的最大值;
12、->?c;????當(dāng)命令輸入錯誤而又無法改變(多行語句情形)時,只要在分號出現(xiàn)前就可以用?c來取消該條命令
13、mysql>?drop?database?庫名;?????????刪庫;
14、mysql>?drop?table?表名;????刪表;
(命令在DOS的\mysql\bin目錄下執(zhí)行)
mysqldump??mysql?blog??>?blog.data?-u?root?-p?????????備份數(shù)據(jù)庫;
myaql?blog?
15、修改密碼
使用mysqladmin:
運(yùn)行-->cmd
c:\mysql\bin>?mysqladmin?-u?root?-p?password?mypasswd
令后,需要輸入root的原密碼,然后root的密碼將改為mypasswd。把命令里的root改為你的用戶名,
你自己的密碼了。
--------------以上文章出處:
-------------------------------
另外,開啟數(shù)據(jù)庫命令:mysqld --console (不要急著退出,否則關(guān)閉數(shù)據(jù)庫)
(或者采用:net?start?mysql)
關(guān)閉數(shù)據(jù)庫: mysqladmin -h localhost -p -u root shutdown
(或者采用:net?stop?mysql)
然后輸入密碼即可。
---------------------------------------------------
總結(jié)
以上是生活随笔為你收集整理的windows下mysql命令_windows下的mysql命令使用的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: arraylist 后往前遍历_面试官:
- 下一篇: 阿里云mysql强制走索引_MYSQL中