用户管理:
解析:mysq的用户账号包含两个部分:username@hostname
mysql的用户一般保存在mysql自带的mysql库中的user表中
查看用户:select host,user,password from mysql.user ;
创建用户:
CREATE USER ‘username‘@‘hostname‘’ IDENTIFIED BY '密码'
注意:引号要加上
删除用户:
更改用户名:
RENAME USER old_user TO new_user
为用户设置密码:
SET PASSWORD FOR user =PSSWORD('新密码')
权限管理:
权限类型(privileges ):
库级别:
alter
alter routine 存储历程
create
create routine 存储过程,存储函数
create view
delete
drop
execute
grant option 将自己的权限复制给别的用户
index 索引
show view
表级别:
select
insert
update
delete
字段级别
select
update
insert
管理类
程序类
授权GRANT:
基础: grant 权限类型 ON 库 TO 用户名
例:授予所有权限给用户:GRANT ALL PRIVILEGES ON *.* TO ‘username’@‘%’ IDENTIFIED BY 'password’
官方:
GRANT
priv_type [(column_list)]
[, priv_type [(column_list)]] ...
ON [object_type] priv_level
TO user_specification [, user_specification] ...
[REQUIRE {NONE | ssl_option [[AND] ssl_option] ...}]
[WITH with_option ...]
查看用户权限:
SHOW GRANTS FOR用户名
回收权限:
一般:
REVOKE 权限类型 ON 库名 FROM 用户名;
官方:
REVOKE
priv_type [(column_list)]
[, priv_type [(column_list)]] ...
ON [object_type] priv_level
FROM user [, user] ...
REVOKE ALL PRIVILEGES, GRANT OPTION
FROM user [, user] ...
REVOKE PROXY ON user
FROM user [, user] ...
help contents
SHOW PROCESSLIST;