MySQL常用命令

2021-04-26 20:40:55 字數 1183 閱讀 5177

前面為命令,後面""中內容為該命令的作用。

net start mysql [啟動mysql服務]

net stop mysql  [關閉mysql服務]

mysql -uroot -p12345678 [連線資料庫]

show databases          [顯示當前存在的資料庫]

use 資料庫名            [選擇要使用的資料庫]

create 資料庫名         [新建乙個資料庫]

show tables             [顯示當前資料庫中已存在的表]

create table person

(id varchar(32) not null primary key,

name varchar(20) not null,

password varchar(20) not null

);                      [建立乙個表]

describe 表名           [顯示表的結構]

insert into person values("jay chou","周杰倫","12345678");    [向表中插入一條記錄,注:person為表名]

drop table 要刪除的表名 [刪除表]

delete from 表名        [刪除表中全部記錄]

update 表名 set 屬性名=值 [更新表中資料]

select version() [查詢伺服器的版本]

select current_date [查詢伺服器當前日期]

select now()        [查詢伺服器當前時間]

select user()       [檢視當前使用者]

source 檔案路徑(*.sql)[匯入sql檔案中的命令,進行資料庫的建立等操作]

load data local infile'檔案的路徑' into table 表名 [向表中插入純資料格式的資料]

select * from 表名  [查詢表中資料]

select * from 表名 where 屬性=值  [查詢指定資料]

select * from 表名 where 屬性 like '%關鍵字%'  [模糊查詢前後包含任意數目字元的含有關鍵字]

select count(*) from 表名  [查詢表中共有多少條記錄]

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...