顯示本地root用戶權限
show grants for root@localhost\G;
顯示任意%域用戶權限
show grants for root\G;
查詢全部用戶
select * from mysq.user;
給某個用戶受權語法
grant all privileges on *.* to a@'%' identified by '123'; //受權全部權利
grant 具體權限 on 表 to 用戶名@'域' identified by 'password';
域包括本地與遠程:localhost|'%'|'127.0.3.*'
具體權限包括:
全局管理權限:
FILE 在mYSql服務器上讀寫文件;
PROCESS 顯示或殺死屬於其餘用戶的線程;
RELOAD 重載訪問控制表,刷新日誌等;
SHUTDOWN 關閉mysql服務
;
數據庫/數據表的權限修改:
create|alter|select|insert|update|delete|drop|index(索引)
特別的權限:
all | usage
去除權限
revoke all on表名 from 用戶名@'%'或者Localhost ;
建立索引
create index 索引名 on 表名(列名);
添加索引
alter table 表名 add index 索引名 (列名,列名。。。);
刪除索引
drop index 索引名 on 表名;
alter table 表名 drop index 索引名;
Mysql explain
Mysql explain 來查詢sql語句的效率如何。。。
MySql explain select_type包括
一 simple-----最簡單的查詢,沒有任何依賴
二 primary -------最外層查詢
三
diriver --------驅動查詢 ;
四
union ,union result 查詢合併結果
五
subquery --------子查詢
六
dependent subquery
mysql 索引細則能夠參考http://www.perfgeeks.com/?p=460的內容;
刪除觸發器
drop trigger tri_name;
外鍵關聯刪除,更新很方便!!! 添加外鍵 alter table borrowRecord add constraint FK_STUDENT foreign key(studentid) references student(studentid) on delete cascade on update cascade;