极客学院
1.MySQL数据库管理的基本任务
MySQL除了数据库的创建,添加/查询/删除数据是不够的,还有数据库的管理问题,主要包括运行时间,数据备份,安全和访问控制,性能优化,根据日志进行排查和统计等。
2.MySQL授权表
主要是五个授权表,都是mysql数据库下,分别是user,host,db,tables_priv,columns_priv
XAMPP进行连接之后,会出现四个默认的数据库:information_schema,mysql,performance_schema,phpmyadmin
四个表详细信息可以参考文章:
http://www.imooc.com/wenda/detail/355577
https://blog.youkuaiyun.com/XavierDarkness/article/details/77196714
XAMPP连接中的默认mysql数据库下面也有user,host,db,tables_priv,columns_priv这些表。
3.MySQL权限控制
除了通过界面化的软件进行权限控制,还可以通过SQL语句grant,revoke,flush,drop user,show grants等进行权限控制。
授予权限:
-- with grant option 表示被授予权限的用户可以把这些权限赋予别的用户
grant all privileges on dbname.tablename to username@host identified by 'password' with grant option;
grant all privileges on test.websites to root@localhost identified by '123321' with grant option;
grant usage,select,insert,update,delete,show view,create temporary tables,excute on test.websites to root@localhost identified by '123321' with grant option;
关于权限更多可以参考文章:
https://blog.youkuaiyun.com/anzhen0429/article/details/78296814
https://www.cnblogs.com/bethal/p/5512755.html
刷新权限:
flush privileges;
收回权限:
revoke delete on test.websites from root@localhost;
删除用户:
drop user root@localhost;
查看权限:
show grants for root@localhost;