1.查看全部的用戶:
select user,host from mysql.user\G;
2.新建用戶:
create user ‘用戶名’@‘主機名’ identified by ‘用戶密碼’;
3.Mysql用戶權限:
ALL:所有可用的權限
CREATE:創建庫、表以及索引
ALTER:修改表
DELETE:刪除表
DROP:刪除庫、表和視圖
INSERT:插入表或列
SELECT:檢索表或列的數據
CREATE_VIEW:創建視圖
SHOW_DATABASES:列出數據庫
LOCK_TABLES:鎖定表
4.用戶授權
格式: grant 權限 on 數據庫.* to 用戶名@登錄主機 identified by ‘密碼’;
例如:
//賦予所有權限
grant all privileges on testDB.* to test@localhost identified by '1234';
//賦予部分權限
grant select,update on testDB.* to test@localhost identified by '1234';
5.查看用戶權限
show grants for ‘用戶名’@‘主機名’
6.刷新系統權限表
flush privileges;