MySQL常見命令(一)

2021-10-24 22:11:29 字數 1383 閱讀 5650

方式一:計算機-右擊管理一服務

方式二:通過管理員身份執行

net start 服務名(啟動服務)

net stop 服務名(停止服務)

方式一:通過mysq1自帶的客戶端

只限於root使用者

方式二:通過windows自帶的客戶端

登入:mysql [-h主機名 -p埠號] -u使用者名稱 -p密碼

退出:exit或ctrl+c

1.檢視當前所有的資料庫

show databases;

2.開啟指定的庫

use 庫名

3.檢視當前庫的所有表

show tables;

4.檢視其它庫的所有表

show tables from 庫名;

5.建立表

create table表名(

列名 列型別,

列名 列型別

);6.檢視表結構

desc 表名;

7.查春伺服器的版本

方式一:登入到mysq1服努端

select version();

方式二:沒有登入到nysq1服務端

mysql --version

或 mysql --v

例子: mysql> show databases; #展示所有資料庫

mysql> use sys; #開啟資料庫

mysql> show tables; #檢視當前庫的所有表

mysql> select database(); #檢視當前位置

mysql> desc test1; #檢視表結構

mysql> select * from test1; #展示表裡面的所有東西

mysql> insert into test1(id,name) values(1,'hello'); #插入資料

mysql> insert into test1(id,name) values(2,'word'); #插入資料

mysql> select * from test1;

+------+-------+

| id | name |

+------+-------+

| 1 | hello |

| 2 | word |

+------+-------+

1.不區分大小寫,但建議關鍵宇大寫,表名、列名小寫

2.每條命令最好用分號結尾

3.每條命令根據需要,可以進行縮排或換行

4.注釋

單行注釋: #注釋文字、--注釋文字

多行注釋: /*注釋文字*/

MySQL常見命令

mysql開啟第一步看有哪些資料庫 1.顯示資料庫命令 show databases 2.預設資料庫有 1.information schema 原資料庫資訊 2.mysql 資料庫使用者資訊 3.performance schema 收集效能資訊 4.test測試資訊 也屬於使用者資料庫 3.選擇...

mysql常見命令

1.檢視當前所有資料庫 show databases 2.開啟指定資料庫 use 庫名 3.檢視當前庫的所有表 show tables from 庫名 4.建立表 create table 表名 列名 列型別,列名 列型別,5.檢視表結構 desc 表名 6.檢視伺服器版本 方式一 登陸到mysql...

MySQL常見命令

檢視當前所有資料庫 show databases 開啟指定的庫 use 庫名 檢視當前庫的所有表 show tables 檢視其他庫的所有表 show tables from 庫名 建立表 create table 表名 列名 列型別 列明 列型別 檢視表結構 desc 表名 檢視伺服器版本 1 登...