mysql 的相關操作 mysql 相關操作

2021-10-18 21:03:46 字數 847 閱讀 6930

$ mysql -u root -p   回撤後輸入密碼 123456, 進入mysql

資料庫簡單操作

(1)建立資料庫:create database 資料庫名稱;

(2)檢視資料庫:show databases;

(3)刪除資料庫:drop database 資料庫名稱;

(4)開啟資料庫:use 資料庫名稱;

資料表簡單操作

(1)顯示某個資料庫中的所有表:show tables;

(2)顯示資料表的結構:desc 表名;

(3)建立資料表:create tabel 表名(欄位名稱 字段型別, ……);

(4)新增新列:alter table 列名 add 欄位名稱 字段型別;

(5)刪除資料表:drop table 表名;

(6)複製表:create table 新錶名 like 被複製表名;

(7)修改預設值:alter table表名alter column欄位名drop default; (若本身存在預設值,則先刪除)

alter table表名 alter column欄位名 set default預設值;(若本身不存在則可以直接設定)

(8)  清空表: truncate 表名; delete from 表名;

資料簡單操作

(1)查詢資料:select * from 表名 where 字段 = 值;

(2)插入資料:insert into 表名 (欄位1, ……) values (值1, ……);

(3)更新資料:update 表名 字段=值,...,欄位n=值n where 字段=值;

(4)刪除資料:delete from 表名 where 字段=值;

mysql相關操作 mysql 相關操作

1 登入 mysql u root p 2 檢視當前有的資料庫 show databases 3 建立資料庫 create database 資料庫名 4 操作 使用 資料庫 use 資料庫名 5 檢視有哪些表 show tables 6 建立表 create table 表名 7 刪除表 drop...

mysql 的相關操作 MySQL相關操作知識

1 解決客戶端聯不上mysql伺服器的問題 grant all privileges on to root identified by with grant option flush privileges 2 登陸mysql mysql u root p 123456 3 檢視所有資料庫 show ...

mysql相關操作

1.遠端登入mysql mysql h ip u root p 密碼 2.建立使用者 格式 grant 許可權 on 資料庫.to 使用者名稱 登入主機 identified by 密碼 例1 增加乙個test1使用者,密碼為123456,可以在任何主機上登入,並對所有資料庫有查詢,增加,修改和刪除...