mysql>grant usage on *.* to 'sealy'@'localhost' IDENTIFIED by "123456" with grant option;
上面這種只支持mysql服務器本地登陸。mysql
1.2 添加一個任意Ip登陸的用戶:sql
mysql>grant usage on *.* to 'sealy'@'%' IDENTIFIED by "123456" with grant option;
二、受權test用戶擁有testDB數據庫的全部權限(某個數據庫的全部權限):數據庫
2.1 爲某個用戶授予全部權限:服務器
mysql>grant all privileges on testDB.* to 'test'@'%' identified by '123456'; mysql>flush privileges; --刷新系統權限表
格式:grant 權限 on 數據庫.* to 用戶名@登陸主機 identified by "密碼"; ide
2.2 爲某個用戶授予部分權限:spa
mysql>grant select,update on 'testDB'.* to 'test'@'%' identified by '123456'; mysql>flush privileges;
2.5 受權test用戶擁有全部數據庫的某些權限: code
mysql>grant select,delete,update,create,drop on *.* to 'test'@'%' identified by "123456";
--test用戶對全部數據庫都有select,delete,update,create,drop 權限。blog
--@"%" 表示對全部非本地主機受權,不包括localhost。it
--對localhost受權:加上一句grant all privileges on testDB.* to 'test'@'localhost' identified by '123456';便可。io