管理员给abc授权MYSQL所有数据库权限
grant all on *.* to abc@'%';
grant select on testdb.* to dba@localhost; -- abc 可以查询 testdb 中的表。
授权后abc可以列出其它之前访问不到的数据库。撤销权限。注意需要abc用户重新连接才有效或者刷新权限。
注意之前单独授予了test的数据库的权限,REVOKE ALL不会对这条授权产生影响,所以用户依然可以对test数据库有权限。需要单独对这个授权进行回收才可以。
REVOKE ALL ON *.* FROM abc@'%'
SHOW GRANTS 查权限
允许本地 IP 访问 localhost, 127.0.0.1
create user 'test'@'localhost' identified by '123456';
允许外网 IP 访问
create user 'test'@'%' identified by '123456';
刷新授权
flush privileges;
授予新用户通过外网IP对于该数据库的全部权限
grant all privileges on `testdb`.* to 'test'@'%' identified by '123456';
删除用户
delete from mysql.user where user='用户名';