mysql常用命令行表
1、系統管理
mysql -h主機位址 -u使用者名稱 -p
連線mysql(在mysql/bin)
exit
退出mysql命令
mysqladmin -u使用者名稱 -p舊密碼 password新密碼
修改密碼(在mysql/bin)
grantselect[insert][,update][,delete]on資料庫.*to使用者名稱@localhost("%", 表示任何主機)identifiedby "密碼"
增加使用者
mysqldump –u root –p opt資料庫名》備份檔案名
備份資料庫(在mysql/bin)
mysql –u root –p < batch file (例如備份檔案名)
使用批處理
mysql.server start
啟動伺服器
mysql.server stop
停止伺服器
msql.server log
2、查詢命令
select version()
查詢版本號
select current_date
查詢當前日期
3、顯示命令
show databases
顯示資料庫列表
show tables 顯示庫中的資料表
describe 表名 顯示資料表的結構
select * from 表名 顯示表中的記錄
select what_to_select from which table [whereconditions_to_satisfy and (or) where conditions_to_satisfy] 從乙個表中檢索資料『滿足條件』
select 欄位1,欄位2,… from 表名 顯示特定列的值
select * from 表名 order by 欄位名 排序行
select 欄位1,包含欄位2的表示式as 新字段 from 表名 字段值運算操作
select 欄位1 is null(is not null) 空值操作
select*from表名where欄位名like(not like) 「 字元」
注: 允許使用「_」匹配任何單個字元, 而「%」 匹配任意數目字元 模式匹配
select * from表名where欄位名regexp(not regexp)或者rlike(not rlike) 「.」匹配任何單個的字元 乙個字元類[…]匹配方框內任何字元。例如[a],[asd],[az] 匹配任何小寫字母,[09] 匹配任何數
字。 「*」匹配零個或者多個在它前面的東西。 正規表示式區分大小寫[aa] 。 如果它出現在被測試值的任何地方,模式都匹配。 定位,在模式開始處用「^」,結尾處用「$」,例如「^b」
擴充套件正規表示式
select count(*) from 表名
select 欄位名,count(*) from 表名 group by 欄位名 行計數
4、編輯命令
use database 庫名
使用的資料庫
create database 庫名
建立資料庫
create table 表名
在資料庫中建立表
ins
mysql基本常用命令 MySQL常用命令(一)
cmd提示框中的mysql基礎命令 一 命令 連線mysql伺服器 mysql h localhost u root p 展示所有資料庫 show databases 選擇資料庫 use database 展示所選資料下所有表 show tables 設定資料庫編碼 set names gbk 用s...
mysql巡檢常用命令 mysql 常用命令
客戶端連線 進入命令列,windows cmd,連線 mysql u 使用者名稱 p密碼 h 伺服器ip位址 p 伺服器端mysql埠號 d 資料庫名 注意 1 伺服器端口標誌 p一定要大些以區別於使用者 p,如果直接連線資料庫標誌 d也要大寫 2 如果要直接輸入密碼 p後面不能留有空格如 pmyp...
mysql常用命令總結 mySql常用命令總結
總結一下自己常用的mysql資料庫的常用命令 mysql u root p 進入mysql bin目錄後執行,回車後輸入密碼連線。資料庫操作 1 create database dbname 建立資料庫,資料庫名為dbname 2 create database todo default chara...